]> git.ipfire.org Git - thirdparty/git.git/commit
mv: refuse to move sparse paths
authorDerrick Stolee <dstolee@microsoft.com>
Fri, 24 Sep 2021 15:39:13 +0000 (15:39 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Sep 2021 17:31:02 +0000 (10:31 -0700)
commit93d2c160411e2a3309a8e2f55eb53bd6c78b7262
tree91303b164be272b64d1b33c4b7048758779f1398
parentd7c4415e554ac62e49c9616bca5087b4b1310e5a
mv: refuse to move sparse paths

Since cmd_mv() does not operate on cache entries and instead directly
checks the filesystem, we can only use path_in_sparse_checkout() as a
mechanism for seeing if a path is sparse or not. Be sure to skip
returning a failure if '-k' is specified.

To ensure that the advice around sparse paths is the only reason a move
failed, be sure to check this as the very last thing before inserting
into the src_for_dst list.

The tests cover a variety of cases such as whether the target is tracked
or untracked, and whether the source or destination are in or outside of
the sparse-checkout definition.

Helped-by: Matheus Tavares Bernardino <matheus.bernardino@usp.br>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/mv.c
t/t7002-mv-sparse-checkout.sh [new file with mode: 0755]