]> git.ipfire.org Git - thirdparty/git.git/commit - refs.c
refs: omit dangling symrefs when using GIT_REF_PARANOIA
authorJeff King <peff@peff.net>
Fri, 24 Sep 2021 18:42:38 +0000 (14:42 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Sep 2021 19:36:45 +0000 (12:36 -0700)
commit6d751be4b66180679e8bc03fc22b14b4245067a8
treeb0fbd1d9fe5876f36f391554b1a89f73e65c10fc
parent8dccb2244c81258cf9f3480c4102d14e30978194
refs: omit dangling symrefs when using GIT_REF_PARANOIA

Dangling symrefs aren't actually a corruption problem. It's perfectly
fine for refs/remotes/origin/HEAD to point to an unborn branch. And in
particular, if you are trying to establish reachability, a symref that
points nowhere doesn't matter either way. Any ref it could point to will
be examined during the rest of the traversal.

It's possible that a symref pointing nowhere _could_ be a sign that the
ref it was meant to point to was deleted accidentally (e.g., via
corruption). But there is no particular reason to think that is true for
any given case, and in the meantime, GIT_REF_PARANOIA kicking in
automatically for some operations means they'll fail unnecessarily.

So let's loosen it just a bit. The new test in t5312 shows off an
example that is safe, but currently fails (and no longer does after this
patch).

Note that we don't do anything if the caller explicitly asked for
DO_FOR_EACH_INCLUDE_BROKEN. In that case they may be looking for
dangling symrefs themselves, and setting GIT_REF_PARANOIA should not
_loosen_ things from what the caller asked for.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
t/t5312-prune-corruption.sh