aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-03-20 17:33:06 +0100
committerJunio C Hamano <gitster@pobox.com>2017-04-14 03:54:31 -0700
commit68fb02e40de22d38cb8988c524e31f93dc40c224 (patch)
tree23e7a216b9c2155d655c751b1c9971aab5a91830
parentadac8115a6e7f9841c48e4fe48b74e0ce652ef58 (diff)
downloadgit-68fb02e40de22d38cb8988c524e31f93dc40c224.tar.gz
git-68fb02e40de22d38cb8988c524e31f93dc40c224.tar.xz
get_ref_dir(): don't call read_loose_refs() for "refs/bisect"
Since references under "refs/bisect/" are per-worktree, they have to be sought in the worktree rather than in the main repository. But since loose references are found by traversing directories, the reference iterator won't even get the idea to look for a "refs/bisect/" directory in the worktree if there is not a directory with that name in the main repository. Thus `get_ref_dir()` manually inserts a dir_entry for "refs/bisect/" whenever it reads the entry for "refs/". The current code then immediately calls `read_loose_refs()` on that directory. But since the dir_entry is created with its `incomplete` flag set, any traversal that gets to this point will read the directory automatically. So there is no need to call `read_loose_refs()` explicitly; the lazy mechanism suffices. And in fact, the attempt to `read_loose_refs()` was broken anyway. That function needs its `dirname` argument to have a trailing `/` character, but the invocation here was passing it "refs/bisect" without a trailing slash. So `read_loose_refs()` would read `$GIT_DIR/refs/bisect" correctly, but if it found an entry "foo" in that directory, it would try to read "$GIT_DIR/refs/bisectfoo". Normally it wouldn't find anything at that path, but the failure was canceled out because `get_ref_dir()` *also* forgot to reset the `REF_INCOMPLETE` bit on the dir_entry. So the read was attempted again when it was accessed, via the lazy mechanism, and this time the read was done correctly. This code has been broken since it was first introduced. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--refs/files-backend.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 4d705b403..2a0538dea 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -191,8 +191,6 @@ static struct ref_dir *get_ref_dir(struct ref_entry *entry)
"refs/bisect/",
12, 1);
add_entry_to_dir(dir, child_entry);
- read_loose_refs("refs/bisect",
- &child_entry->u.subdir);
}
}
entry->flag &= ~REF_INCOMPLETE;