summaryrefslogtreecommitdiff
path: root/pack-objects.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-04-10 03:04:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-04-10 05:40:48 (GMT)
commit022046107186746913ef43a33f4b6862817bf6da (patch)
tree8771b6579f937b523921e6630e1c2dc279b8e893 /pack-objects.h
parent5ff4b920ebeadfa640f1b7d5929f58bb180a0519 (diff)
downloadgit-022046107186746913ef43a33f4b6862817bf6da.zip
git-022046107186746913ef43a33f4b6862817bf6da.tar.gz
git-022046107186746913ef43a33f4b6862817bf6da.tar.bz2
repository: mark the "refs" pointer as private
The "refs" pointer in a struct repository starts life as NULL, but then is lazily initialized when it is accessed via get_main_ref_store(). However, it's easy for calling code to forget this and access it directly, leading to code which works _some_ of the time, but fails if it is called before anybody else accesses the refs. This was the cause of the bug fixed by 5ff4b920eb (sha1-name: do not assume that the ref store is initialized, 2020-04-09). In order to prevent similar bugs, let's more clearly mark the "refs" field as private. In addition to helping future code, the name change will help us audit any existing direct uses. Besides get_main_ref_store() itself, it turns out there is only one. But we know it's OK as it is on the line directly after the fix from 5ff4b920eb, which will have initialized the pointer. However it's still a good idea for it to model the proper use of the accessing function, so we'll convert it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-objects.h')
0 files changed, 0 insertions, 0 deletions