Commit 0238c63
committed
mingw: Fix unlink for open files
Files that were opened by a (possibly another) process either for
read or for failed to be replaced by Git on checkout.
If a file is opened with FILE_SHARE_DELETE share mode, it is possible
to delete or rename the file, but it is *not possible* to create a
new file until the file's handle is closed.
To overcome this, unlink now renames files that are not writable before
actually unlinking them.
If rename fails, then the file either doesn't exist, or it is open
without share permissions. On this case, it is still possible to unlink
the file. The file will effectively be deleted when it is closed.
On this case, preserve the existing behavior.
If rename succeeds, unlink the temporary file, making it possible for
the real file name to be reused.
Fixes git#1653.
Signed-off-by: Orgad Shaneh <orgads@gmail.com>1 parent 21f188e commit 0238c63
3 files changed
+115
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
534 | 578 | | |
535 | 579 | | |
536 | 580 | | |
| |||
544 | 588 | | |
545 | 589 | | |
546 | 590 | | |
547 | | - | |
| 591 | + | |
548 | 592 | | |
549 | 593 | | |
550 | 594 | | |
| |||
553 | 597 | | |
554 | 598 | | |
555 | 599 | | |
556 | | - | |
| 600 | + | |
557 | 601 | | |
558 | 602 | | |
559 | 603 | | |
| |||
614 | 658 | | |
615 | 659 | | |
616 | 660 | | |
617 | | - | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
618 | 664 | | |
619 | 665 | | |
620 | 666 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
271 | 272 | | |
272 | 273 | | |
273 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
0 commit comments