Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-04-22 23:42:55 +0300
committerJunio C Hamano <gitster@pobox.com>2020-04-22 23:42:55 +0300
commit95ca48973d351cdd40e6497b82ab85b95e432fab (patch)
tree9e275d3dad4046ec1f10fde07ee10cee21231449
parentbc20556505e4c337d34d1e5272c9bdc274dd081a (diff)
parent022046107186746913ef43a33f4b6862817bf6da (diff)
Merge branch 'jc/missing-ref-store-fix'
We've left the command line parsing of "git log :/a/b/" broken for about a full year without anybody noticing, which has been corrected. * jc/missing-ref-store-fix: repository: mark the "refs" pointer as private sha1-name: do not assume that the ref store is initialized
-rw-r--r--refs.c8
-rw-r--r--repository.h8
-rw-r--r--sha1-name.c4
-rwxr-xr-xt/t4208-log-magic-pathspec.sh4
4 files changed, 16 insertions, 8 deletions
diff --git a/refs.c b/refs.c
index 1ab0bb54d3..b8759116cd 100644
--- a/refs.c
+++ b/refs.c
@@ -1852,14 +1852,14 @@ static struct ref_store *ref_store_init(const char *gitdir,
struct ref_store *get_main_ref_store(struct repository *r)
{
- if (r->refs)
- return r->refs;
+ if (r->refs_private)
+ return r->refs_private;
if (!r->gitdir)
BUG("attempting to get main_ref_store outside of repository");
- r->refs = ref_store_init(r->gitdir, REF_STORE_ALL_CAPS);
- return r->refs;
+ r->refs_private = ref_store_init(r->gitdir, REF_STORE_ALL_CAPS);
+ return r->refs_private;
}
/*
diff --git a/repository.h b/repository.h
index 040057dea6..6534fbb7b3 100644
--- a/repository.h
+++ b/repository.h
@@ -67,8 +67,12 @@ struct repository {
*/
struct parsed_object_pool *parsed_objects;
- /* The store in which the refs are held. */
- struct ref_store *refs;
+ /*
+ * The store in which the refs are held. This should generally only be
+ * accessed via get_main_ref_store(), as that will lazily initialize
+ * the ref object.
+ */
+ struct ref_store *refs_private;
/*
* Contains path to often used file names.
diff --git a/sha1-name.c b/sha1-name.c
index 6561cd9097..0b8cb5247a 100644
--- a/sha1-name.c
+++ b/sha1-name.c
@@ -1815,8 +1815,8 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
cb.repo = repo;
cb.list = &list;
- refs_for_each_ref(repo->refs, handle_one_ref, &cb);
- refs_head_ref(repo->refs, handle_one_ref, &cb);
+ refs_for_each_ref(get_main_ref_store(repo), handle_one_ref, &cb);
+ refs_head_ref(get_main_ref_store(repo), handle_one_ref, &cb);
commit_list_sort_by_date(&list);
return get_oid_oneline(repo, name + 2, oid, list);
}
diff --git a/t/t4208-log-magic-pathspec.sh b/t/t4208-log-magic-pathspec.sh
index 4c8f3b8e1b..6cdbe4747a 100755
--- a/t/t4208-log-magic-pathspec.sh
+++ b/t/t4208-log-magic-pathspec.sh
@@ -55,6 +55,10 @@ test_expect_success '"git log -- :/a" should not be ambiguous' '
git log -- :/a
'
+test_expect_success '"git log :/any/path/" should not segfault' '
+ test_must_fail git log :/any/path/
+'
+
# This differs from the ":/a" check above in that :/in looks like a pathspec,
# but doesn't match an actual file.
test_expect_success '"git log :/in" should not be ambiguous' '