Skip to content

pr-git-2356/ZamboniL/mv-detect-non-existing-target-folder-v4

tagged this 26 Jul 20:17
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  | 37 ++++++++++++++++++++++-
 t/t7001-mv.sh | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+), 1 deletion(-)

base-commit: 9a0c4701dcd5725c4184599322b52933ff5005ca

Submitted-As: https://lore.kernel.org/git/pull.2356.v4.git.git.1785097071.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
Assets 2
Loading