aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/mv.c
diff options
context:
space:
mode:
authorShaoxuan Yuan <shaoxuan.yuan02@gmail.com>2022-08-09 20:09:10 +0800
committerJunio C Hamano <gitster@pobox.com>2022-08-10 13:57:50 -0700
commitda6fe05b3d624ad5b40472eebfe0499c15ecc93d (patch)
tree13c13771cca4c1ccd6d4fbcf006c504fb90a1d6d /builtin/mv.c
parentadvice.h: add advise_on_moving_dirty_path() (diff)
downloadgit-da6fe05b3d624ad5b40472eebfe0499c15ecc93d.tar.gz
git-da6fe05b3d624ad5b40472eebfe0499c15ecc93d.zip
mv: check overwrite for in-to-out move
Add checking logic for overwriting when moving from in-cone to out-of-cone. It is the index version of the original overwrite logic. Helped-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Shaoxuan Yuan <shaoxuan.yuan02@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/mv.c')
-rw-r--r--builtin/mv.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/builtin/mv.c b/builtin/mv.c
index d80adf8de5..4b67bd096a 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -376,6 +376,18 @@ dir_check:
goto act_on_entry;
}
+ if (ignore_sparse &&
+ (dst_mode & (SKIP_WORKTREE_DIR | SPARSE)) &&
+ index_entry_exists(&the_index, dst, strlen(dst))) {
+ bad = _("destination exists in the index");
+ if (force) {
+ if (verbose)
+ warning(_("overwriting '%s'"), dst);
+ bad = NULL;
+ } else {
+ goto act_on_entry;
+ }
+ }
/*
* We check if the paths are in the sparse-checkout
* definition as a very final check, since that