mv: add check_dir_in_index() and solve general dir check issue
commitb91a2b6594a1da7d4d2f936f7db25bfa5a3d775e
authorShaoxuan Yuan <shaoxuan.yuan02@gmail.com>
Thu, 30 Jun 2022 02:37:37 +0000 (30 10:37 +0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Jul 2022 21:50:16 +0000 (1 14:50 -0700)
treea5f8f4c59962739e6dc3cf784fe4cebafae4fbc8
parent24ea81d9ac401731c222b28097b339aa0d2d316d
mv: add check_dir_in_index() and solve general dir check issue

Originally, moving a <source> directory which is not on-disk due
to its existence outside of sparse-checkout cone, "giv mv" command
errors out with "bad source".

Add a helper check_dir_in_index() function to see if a directory
name exists in the index. Also add a SKIP_WORKTREE_DIR bit to mark
such directories.

Change the checking logic, so that such <source> directory makes
"giv mv" command warns with "advise_on_updating_sparse_paths()"
instead of "bad source"; also user now can supply a "--sparse" flag so
this operation can be carried out successfully.

Helped-by: Victoria Dye <vdye@github.com>
Helped-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/mv.c
t/t1092-sparse-checkout-compatibility.sh
t/t7002-mv-sparse-checkout.sh