@matheusbsbs / matheus-bagliano / commits / 4fddf5798d
Fork 0

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>

Junio C Hamano committed Oct 1, 2006 at 22:22 UTC 4fddf5798d8a0eb112c60a05272a2d9407eafc8f
2 files changed +20
builtin-mv.c
+1
@@ -278,6 +278,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
278 for (i = 0; i < deleted.nr; i++) {
279 const char *path = deleted.items[i].path;
280 remove_file_from_cache(path);
281 + cache_tree_invalidate_path(active_cache_tree, path);
282 }
283
284 if (active_cache_changed) {
t/t7001-mv.sh
+19
@@ -86,4 +86,23 @@ test_expect_success \
86 'move into "."' \
87 'git-mv path1/path2/ .'
88
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 +
108 test_done