diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-02-04 08:59:17 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-05 09:44:10 +0100 |
commit | 744dacd3f5045240a304e687f3ef7135398e7865 (patch) | |
tree | 2f79230a6d792514f78c9344661158f1b6b19b5a /t/t7001-mv.sh | |
parent | git-add: adjust to the get_pathspec() changes. (diff) | |
download | git-744dacd3f5045240a304e687f3ef7135398e7865.tar.xz git-744dacd3f5045240a304e687f3ef7135398e7865.zip |
builtin-mv: minimum fix to avoid losing files
An incorrect command "git mv subdir /outer/space" threw the
subdirectory to outside of the repository and then noticed that
/outer/space/subdir/ would be outside of the repository. The
error checking is backwards.
This fixes the issue by being careful about use of the return
value of get_pathspec(). Since the implementation already has
handcrafted loop to munge each path on the command line, we use
prefix_path() instead.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7001-mv.sh')
-rwxr-xr-x | t/t7001-mv.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index b1243b4163..fa382c58da 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -118,4 +118,42 @@ test_expect_success "Sergey Vlasov's test case" ' git mv ab a ' +test_expect_success 'absolute pathname' '( + + rm -fr mine && + mkdir mine && + cd mine && + test_create_repo one && + cd one && + mkdir sub && + >sub/file && + git add sub/file && + + git mv sub "$(pwd)/in" && + ! test -d sub && + test -d in && + git ls-files --error-unmatch in/file + + +)' + +test_expect_success 'absolute pathname outside should fail' '( + + rm -fr mine && + mkdir mine && + cd mine && + out=$(pwd) && + test_create_repo one && + cd one && + mkdir sub && + >sub/file && + git add sub/file && + + ! git mv sub "$out/out" && + test -d sub && + ! test -d ../in && + git ls-files --error-unmatch sub/file + +)' + test_done |