pr-git-2356/ZamboniL/mv-detect-non-existing-target-folder-v5
tagged this
30 Jul 11:28
Changes in v5: * extracted the shared "will this move rename on disk?" condition into a needs_worktree_rename() helper used by both the new leading-directory check and the actual rename(), so the two cannot drift, per Junio C Hamano * allocate the dirname copy only when the destination has a slash * reworded the opening of the commit message for clarity, per Junio C Hamano * added tests: moving into an existing directory (destination is normalized to a full path), and moving to a bare filename in the cwd (no leading directory to check) Changes in v4: * reverted to lstat and added has_symlink_leading_path() to refuse a destination that goes through a symbolic link, independent of the link target, per Junio C Hamano's point that Git tracks symlinks and must not follow them here * added new "destination is beyond a symbolic link" message * added tests: symlink as immediate parent and as intermediate component, symlink at the destination, -f does not bypass the symlink refusal, and a regression test that a move through a symlink no longer corrupts the index (see the reproduction reported on the list) Changes in v3: * added ENOTDIR handling and an S_ISDIR check so a non-directory leading path component is caught, as suggested by Junio C Hamano * (v3 used stat() to resolve symlinks; this was reverted in v4 after Junio pointed out symlinks must not be followed) * fixed indentation Changes in v2: * altered the error message to include both source and destination as suggested by Ben Knoble Lucas Zamboni Orioli (2): mv: name both source and destination when rename fails mv: reject a destination whose leading path is missing or a symlink builtin/mv.c | 47 +++++++++++++++++++++-- t/t7001-mv.sh | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 3 deletions(-) base-commit: 9a0c4701dcd5725c4184599322b52933ff5005ca Submitted-As: https://lore.kernel.org/git/pull.2356.v5.git.git.1785410884.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2356.git.git.1784125963694.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2356.v2.git.git.1784812390.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2356.v3.git.git.1784842831.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2356.v4.git.git.1785097071.gitgitgadget@gmail.com