Repository navigation
Commit 2a072db
mv: do not follow a symlink destination when checking it (#15912)
* mv: do not follow a symlink destination when checking it
The overwrite guards ran only when the destination resolved, so -n, -i,
-u, --update=none(-fail) and -b were all skipped for a dangling symlink,
which was then replaced. Check the destination entry with lstat instead,
and use the link's own mtime and mode for -u and the overwrite prompt,
as GNU mv does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mv: fix flaky stdin write and formatting in broken symlink tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mv: keep -u from skipping a directory onto a symlink
-u compared the times before the check that a directory can't replace a
non-directory, so moving a directory into a target directory that holds a
newer symlink of the same name was skipped and reported success. Only skip
when the move itself is possible, and compare the source's own times too.
On Windows, look at the symlink itself when checking that the destination is
writable, as on Unix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 31a2935 commit 2a072db
2 files changed
Lines changed: 82 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
818 | 820 | | |
819 | 821 | | |
820 | 822 | | |
821 | 823 | | |
822 | 824 | | |
823 | 825 | | |
824 | 826 | | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
829 | 839 | | |
830 | 840 | | |
831 | 841 | | |
| |||
1677 | 1687 | | |
1678 | 1688 | | |
1679 | 1689 | | |
1680 | | - | |
| 1690 | + | |
1681 | 1691 | | |
1682 | 1692 | | |
1683 | 1693 | | |
| |||
1689 | 1699 | | |
1690 | 1700 | | |
1691 | 1701 | | |
1692 | | - | |
| 1702 | + | |
1693 | 1703 | | |
1694 | 1704 | | |
1695 | 1705 | | |
| |||
1699 | 1709 | | |
1700 | 1710 | | |
1701 | 1711 | | |
1702 | | - | |
| 1712 | + | |
1703 | 1713 | | |
1704 | 1714 | | |
1705 | 1715 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
533 | 533 | | |
534 | 534 | | |
535 | 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 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
536 | 600 | | |
537 | 601 | | |
538 | 602 | | |
| |||
0 commit comments