Skip to content

Commit 4fddf57

Browse files
author
Junio C Hamano
committed
git-mv: invalidate the removed path properly in cache-tree
The command updated the cache without invalidating the cache tree entries while removing an existing entry. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 82ca505 commit 4fddf57

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

builtin-mv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
278278
for (i = 0; i < deleted.nr; i++) {
279279
const char *path = deleted.items[i].path;
280280
remove_file_from_cache(path);
281+
cache_tree_invalidate_path(active_cache_tree, path);
281282
}
282283

283284
if (active_cache_changed) {

t/t7001-mv.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,23 @@ test_expect_success \
8686
'move into "."' \
8787
'git-mv path1/path2/ .'
8888

89+
test_expect_success "Michael Cassar's test case" '
90+
rm -fr .git papers partA &&
91+
git init-db &&
92+
mkdir -p papers/unsorted papers/all-papers partA &&
93+
echo a > papers/unsorted/Thesis.pdf &&
94+
echo b > partA/outline.txt &&
95+
echo c > papers/unsorted/_another &&
96+
git add papers partA &&
97+
T1=`git write-tree` &&
98+
99+
git mv papers/unsorted/Thesis.pdf papers/all-papers/moo-blah.pdf &&
100+
101+
T=`git write-tree` &&
102+
git ls-tree -r $T | grep partA/outline.txt || {
103+
git ls-tree -r $T
104+
(exit 1)
105+
}
106+
'
107+
89108
test_done

0 commit comments

Comments
 (0)