summaryrefslogtreecommitdiff
path: root/builtin/patch-id.c
diff options
context:
space:
mode:
authorLibravatar Patrick Steinhardt <ps@pks.im>2022-03-01 10:33:46 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-03-01 10:13:46 -0800
commitcd475b3b03809b1b1c664e0dca9f16f815456719 (patch)
tree790f4b5cace267e3cbd1ae9c08bb3541cec91f88 /builtin/patch-id.c
parentfetch: avoid lookup of commits when not appending to FETCH_HEAD (diff)
downloadtgif-cd475b3b03809b1b1c664e0dca9f16f815456719.tar.xz
refs: add ability for backends to special-case reading of symbolic refs
Reading of symbolic and non-symbolic references is currently treated the same in reference backends: we always call `refs_read_raw_ref()` and then decide based on the returned flags what type it is. This has one downside though: symbolic references may be treated different from normal references in a backend from normal references. The packed-refs backend for example doesn't even know about symbolic references, and as a result it is pointless to even ask it for one. There are cases where we really only care about whether a reference is symbolic or not, but don't care about whether it exists at all or may be a non-symbolic reference. But it is not possible to optimize for this case right now, and as a consequence we will always first check for a loose reference to exist, and if it doesn't, we'll query the packed-refs backend for a known-to-not-be-symbolic reference. This is inefficient and requires us to search all packed references even though we know to not care for the result at all. Introduce a new function `refs_read_symbolic_ref()` which allows us to fix this case. This function will only ever return symbolic references and can thus optimize for the scenario layed out above. By default, if the backend doesn't provide an implementation for it, we just use the old code path and fall back to `read_raw_ref()`. But in case the backend provides its own, more efficient implementation, we will use that one instead. Note that this function is explicitly designed to not distinguish between missing references and non-symbolic references. If it did, we'd be forced to always search the packed-refs backend to see whether the symbolic reference the user asked for really doesn't exist, or if it exists as a non-symbolic reference. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/patch-id.c')
0 files changed, 0 insertions, 0 deletions