From 4d2646727997c82c04a82ce38e56d76e7b5d268b Mon Sep 17 00:00:00 2001 From: Olivier Marin Date: Sat, 19 Jul 2008 18:24:46 +0200 Subject: builtin-rm: fix index lock file path When hold_locked_index() is called with a relative git_dir and you are outside the work tree, the lock file become relative to the current directory. So when later setup_work_tree() change the current directory it breaks lock file path and commit_locked_index() fails. This patch move index locking code after setup_work_tree() call to make lock file relative to the working tree as it should be and add a test case. Noticed by Nick Andrew. Signed-off-by: Olivier Marin Signed-off-by: Junio C Hamano --- t/t3600-rm.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 't') diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index f542f0af4..7893d8c40 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -217,4 +217,16 @@ test_expect_success 'Remove nonexistent file returns nonzero exit status' ' ! git rm nonexistent ' +test_expect_success 'Call "rm" from outside the work tree' ' + mkdir repo && + cd repo && + git init && + echo something > somefile && + git add somefile && + git commit -m "add a file" && + (cd .. && + git --git-dir=repo/.git --work-tree=repo rm somefile) && + test_must_fail git ls-files --error-unmatch somefile +' + test_done -- cgit v1.2.1