[PATCH] cache-tree: propagate invalidation up when punting
From: Junio C Hamano <hidden>
Date: 2016-06-15 23:02:25
Subsystem:
the rest · Maintainer:
Linus Torvalds
We punt from "repair"ing the hash tree during a branch switching if it involves having to create a new tree object that does not yet exist in the object store. "mkdir dir && >dir/file && git add dir" followed by "git checkout" is one example, when a tree that records the state of such "dir/" is not in the object store. However, after discovering that we do not have a tree object that records the state of "dir/", we failed to propagate the fact up the callchain to stop the code to attempt populating the level that has "dir/" as its immediate subdirectory. This led the caller detect and report a non-existent error. Reported-by: John Keeping <redacted> Signed-off-by: Junio C Hamano <redacted> --- cache-tree.c | 2 +- t/t0090-cache-tree.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/cache-tree.c b/cache-tree.c
index f951d7d..e3baf42 100644
--- a/cache-tree.c
+++ b/cache-tree.c@@ -398,7 +398,7 @@ static int update_one(struct cache_tree *it, it->entry_count, it->subtree_nr, sha1_to_hex(it->sha1)); #endif - return i; + return to_invalidate ? -1 : i; } int cache_tree_update(struct cache_tree *it,
diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh
index 48c4240..f9648a8 100755
--- a/t/t0090-cache-tree.sh
+++ b/t/t0090-cache-tree.sh@@ -210,4 +210,12 @@ test_expect_success 'partial commit gives cache-tree' ' test_cache_tree ' +test_expect_success 'no phantom error when switching trees' ' + mkdir newdir && + >newdir/one && + git add newdir/one && + git checkout 2>errors && + ! test -s errors +' + test_done
--
2.1.0-391-g57244f3