diff options
author | Han-Wen Nienhuys <hanwen@google.com> | 2022-09-19 16:34:50 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-09-19 11:11:11 -0700 |
commit | 71e5473493612f74244e2fa7a257a868df98be53 (patch) | |
tree | d749311ef5041031f8a5c569a680837d862990f8 /builtin/reflog.c | |
parent | d3fa443f97e3a8d75b51341e2d5bac380b7422df (diff) | |
download | git-71e5473493612f74244e2fa7a257a868df98be53.tar.gz |
refs: unify parse_worktree_ref() and ref_type()
The logic to handle worktree refs (worktrees/NAME/REF and
main-worktree/REF) existed in two places:
* ref_type() in refs.c
* parse_worktree_ref() in worktree.c
Collapse this logic together in one function parse_worktree_ref():
this avoids having to cross-check the result of parse_worktree_ref()
and ref_type().
Introduce enum ref_worktree_type, which is slightly different from
enum ref_type. The latter is a misleading name (one would think that
'ref_type' would have the symref option).
Instead, enum ref_worktree_type only makes explicit how a refname
relates to a worktree. From this point of view, HEAD and
refs/bisect/abc are the same: they specify the current worktree
implicitly.
The files-backend must avoid packing refs/bisect/* and friends into
packed-refs, so expose is_per_worktree_ref() separately.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/reflog.c')
-rw-r--r-- | builtin/reflog.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/reflog.c b/builtin/reflog.c index 57c5c0d061..270681dcdf 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -67,7 +67,8 @@ static int collect_reflog(const char *ref, const struct object_id *oid UNUSED, * Avoid collecting the same shared ref multiple times because * they are available via all worktrees. */ - if (!worktree->is_current && ref_type(ref) == REF_TYPE_NORMAL) + if (!worktree->is_current && + parse_worktree_ref(ref, NULL, NULL, NULL) == REF_WORKTREE_SHARED) return 0; strbuf_worktree_ref(worktree, &newref, ref); |