From patchwork Fri Aug 9 15:37:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13758897 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 125B1198A30 for ; Fri, 9 Aug 2024 15:37:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723217878; cv=none; b=EvUz2HImAPHI2x52+EYlgaRJyeI/ieApe31IBQ/mmqM2eyrnYvy3D+ej0VR0FuwN/YAw7X93n1BXz2+dD/bSB+fiSNVzgTH7sv+RBo81/g8127iBjxxadrmvVTMhR+FKQZNwA9QHm+UV38IslQ6RXljySeKt8+UMSRD4CVxH7ZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723217878; c=relaxed/simple; bh=au1biXVIsRjNNYpNt5mUaIs0KnGccNuF5Bnf/ZYrqoY=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=ORc7JwZXf+4dMxCNH0xvgTjmZeaLaA4rjqYq9M05VTZ3LrvCS0TC0a4XNGcpUV5/R2Fs6BEEU4xtN3dcU7fMlWS6bveEe8CkuAA91Nu0UCev7B1OEwSwoQOkDa5CvOKNZN1g46BrTA+mh+ObS9GhaX9HYtCjnrhN24EuI8ArKz0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aSP87YuB; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aSP87YuB" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-42809d6e719so16287385e9.3 for ; Fri, 09 Aug 2024 08:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723217875; x=1723822675; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=PUQWSqs03eJiDFdjHCzzmlZg/l4rwbN4ahht1+BR/o0=; b=aSP87YuBduIbfki/O7Pmf6IjVySUyWsU7ZIKWjqmdcvmHnqk5KVWMMLQmUmeP9vPZE B6mdhXlOGmlQSq7+6Gkgt+Az638upuwIbInyuRNioeZ9ovLfOuSQrzs5cMS2coRZHlhh 6OihXgfj8enIgZQfT6A5Pv3zXBruhSnANDgTldPnHg4n3z4vyN5NlveEBM8nS5HUAgxW vFPepmlIcKbuAz1xHNlMPwBrZTaJzYTM093xCjM6De+Kogp7oQ0R4ZQ9o/ftdWkLIjNT oyRwNYoSg6tovVVcPFcBqQPP2xmBRpzjJ1R60GczKhtaWDkEnYh1ne/qucQ50GGrLkUz nHuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723217875; x=1723822675; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PUQWSqs03eJiDFdjHCzzmlZg/l4rwbN4ahht1+BR/o0=; b=UV2lfhheFj94hhPVDPDjFq4H/lYV2Cw6YMe0wIjp+lzZWI6MDA++AGlQNnzfHRMJ1u Ay/b8ybJQOqzy4tUjE6gvVXHYZhhQgBCYz5kbyCCGRC4SKWT16higVWiRQIhr8E8M4eV tL97j+SehXsJAli2PRcLZG2E5Du/744N4WE3I+PxrSipEHb3QL86cBzl7E+LlvkBrmv9 YdIg3hI/0K27ieM9ewyvxeCX8CQB8cur9zs0nTzAffSbRKXll+2ktB2tjzedIgtdjpuh m7xpNVaBssqHE+MrufJS3dElsAkQdTI05FKXyuk2+74dVJRhAuD9updjdLxJt6o0aP2G njww== X-Gm-Message-State: AOJu0Yz0GCG0Ag6YnHQREXHA/l9sQVmdTc1lM390B0qzwMV1wISofaKL Y66j5DRWuGLKxLSajMkhZFw8m5E+tXRf7Dw+RyXgxETbrKp3uRbS2wlIjg== X-Google-Smtp-Source: AGHT+IGZVYtLAHoz5HX9owB+/vvF3DmKPtmWC12KP8d3EInCJLplHcTcjulEEjkUucF7VEmgKYoeyA== X-Received: by 2002:a05:600c:190c:b0:426:61af:e1d3 with SMTP id 5b1f17b1804b1-429c3a5ad1dmr16436225e9.31.1723217874599; Fri, 09 Aug 2024 08:37:54 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d27209a69sm5667371f8f.79.2024.08.09.08.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 08:37:54 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Fri, 09 Aug 2024 15:37:49 +0000 Subject: [PATCH v4 1/3] refs: keep track of unresolved reference value in iterators Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Kristoffer Haugsbakk , Jeff King , Patrick Steinhardt , =?utf-8?q?Jean-No=C3=ABl?= Avila , Linus Arver , John Cai , John Cai From: John Cai From: John Cai Since ref iterators do not hold onto the direct value of a reference without resolving it, the only way to get ahold of a direct value of a symbolic ref is to make a separate call to refs_read_symbolic_ref. To make accessing the direct value of a symbolic ref more efficient, let's save the direct value of the ref in the iterators for both the files backend and the reftable backend. Signed-off-by: John Cai --- refs/files-backend.c | 15 ++++++++++++--- refs/iterator.c | 2 ++ refs/ref-cache.c | 5 +++++ refs/ref-cache.h | 2 ++ refs/refs-internal.h | 1 + refs/reftable-backend.c | 10 ++++++++-- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index aa52d9be7c7..210adf644fa 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -245,9 +245,12 @@ static void loose_fill_ref_dir_regular_file(struct files_ref_store *refs, { struct object_id oid; int flag; + const char *referent = refs_resolve_ref_unsafe(&refs->base, + refname, + RESOLVE_REF_READING, + &oid, &flag); - if (!refs_resolve_ref_unsafe(&refs->base, refname, RESOLVE_REF_READING, - &oid, &flag)) { + if (!referent) { oidclr(&oid, the_repository->hash_algo); flag |= REF_ISBROKEN; } else if (is_null_oid(&oid)) { @@ -268,7 +271,11 @@ static void loose_fill_ref_dir_regular_file(struct files_ref_store *refs, oidclr(&oid, the_repository->hash_algo); flag |= REF_BAD_NAME | REF_ISBROKEN; } - add_entry_to_dir(dir, create_ref_entry(refname, &oid, flag)); + + if (!(flag & REF_ISSYMREF)) + referent = NULL; + + add_entry_to_dir(dir, create_ref_entry(refname, referent, &oid, flag)); } /* @@ -886,6 +893,8 @@ static int files_ref_iterator_advance(struct ref_iterator *ref_iterator) iter->base.refname = iter->iter0->refname; iter->base.oid = iter->iter0->oid; iter->base.flags = iter->iter0->flags; + iter->base.referent = iter->iter0->referent; + return ITER_OK; } diff --git a/refs/iterator.c b/refs/iterator.c index d355ebf0d59..75fbe5d72ab 100644 --- a/refs/iterator.c +++ b/refs/iterator.c @@ -29,6 +29,7 @@ void base_ref_iterator_init(struct ref_iterator *iter, { iter->vtable = vtable; iter->refname = NULL; + iter->referent = NULL; iter->oid = NULL; iter->flags = 0; } @@ -199,6 +200,7 @@ static int merge_ref_iterator_advance(struct ref_iterator *ref_iterator) } if (selection & ITER_YIELD_CURRENT) { + iter->base.referent = (*iter->current)->referent; iter->base.refname = (*iter->current)->refname; iter->base.oid = (*iter->current)->oid; iter->base.flags = (*iter->current)->flags; diff --git a/refs/ref-cache.c b/refs/ref-cache.c index 4ce519bbc85..35bae7e05de 100644 --- a/refs/ref-cache.c +++ b/refs/ref-cache.c @@ -34,6 +34,7 @@ struct ref_dir *get_ref_dir(struct ref_entry *entry) } struct ref_entry *create_ref_entry(const char *refname, + const char *referent, const struct object_id *oid, int flag) { struct ref_entry *ref; @@ -41,6 +42,8 @@ struct ref_entry *create_ref_entry(const char *refname, FLEX_ALLOC_STR(ref, name, refname); oidcpy(&ref->u.value.oid, oid); ref->flag = flag; + ref->u.value.referent = xstrdup_or_null(referent); + return ref; } @@ -66,6 +69,7 @@ static void free_ref_entry(struct ref_entry *entry) */ clear_ref_dir(&entry->u.subdir); } + free(entry->u.value.referent); free(entry); } @@ -431,6 +435,7 @@ static int cache_ref_iterator_advance(struct ref_iterator *ref_iterator) level->index = -1; } else { iter->base.refname = entry->name; + iter->base.referent = entry->u.value.referent; iter->base.oid = &entry->u.value.oid; iter->base.flags = entry->flag; return ITER_OK; diff --git a/refs/ref-cache.h b/refs/ref-cache.h index 31ebe24f6cf..5f04e518c37 100644 --- a/refs/ref-cache.h +++ b/refs/ref-cache.h @@ -42,6 +42,7 @@ struct ref_value { * referred to by the last reference in the symlink chain. */ struct object_id oid; + char *referent; }; /* @@ -173,6 +174,7 @@ struct ref_entry *create_dir_entry(struct ref_cache *cache, const char *dirname, size_t len); struct ref_entry *create_ref_entry(const char *refname, + const char *referent, const struct object_id *oid, int flag); /* diff --git a/refs/refs-internal.h b/refs/refs-internal.h index fa975d69aaa..117ec233848 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -299,6 +299,7 @@ enum do_for_each_ref_flags { struct ref_iterator { struct ref_iterator_vtable *vtable; const char *refname; + const char *referent; const struct object_id *oid; unsigned int flags; }; diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c index fbe74c239d3..50a072b97b0 100644 --- a/refs/reftable-backend.c +++ b/refs/reftable-backend.c @@ -455,6 +455,7 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator) struct reftable_ref_iterator *iter = (struct reftable_ref_iterator *)ref_iterator; struct reftable_ref_store *refs = iter->refs; + const char *referent = NULL; while (!iter->err) { int flags = 0; @@ -494,8 +495,12 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator) the_repository->hash_algo); break; case REFTABLE_REF_SYMREF: - if (!refs_resolve_ref_unsafe(&iter->refs->base, iter->ref.refname, - RESOLVE_REF_READING, &iter->oid, &flags)) + referent = refs_resolve_ref_unsafe(&iter->refs->base, + iter->ref.refname, + RESOLVE_REF_READING, + &iter->oid, + &flags); + if (!referent) oidclr(&iter->oid, the_repository->hash_algo); break; default: @@ -523,6 +528,7 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator) continue; iter->base.refname = iter->ref.refname; + iter->base.referent = referent; iter->base.oid = &iter->oid; iter->base.flags = flags; From patchwork Fri Aug 9 15:37:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13758899 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A80D1946B4 for ; Fri, 9 Aug 2024 15:37:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723217881; cv=none; b=ehB0tPkbBvOdEvxoB7uX/uyRwcXeuuwr5d7Nu9PdODvp0ykH5ijfHBD76Oc4QpPzLN7CpmQX07NjYsUFhiJDOPAomNJfIvwv3fOefTlDCBvpLin7SHGzrN2npM9CkYgDWsO08we+NorvKes0sIQVra4ngLkdunc+2WzW4VvxCz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723217881; c=relaxed/simple; bh=vrVGV6mCnVg17qbB8+o8UcQRUlnNSaLNQHxrpKWcNb4=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=Ze3uWVfryY0KwKy2nKjHNZKQh7R1xEhXE639PinfqAjQKQJQZ37B+JlrtyVDoqTU2GTYCWr5KxCUir8iehv6Ocxt29KD8cSzFkhrKAhhi/yUa6ELHipJyIuLUs2GCbmpxn83Dx3NgxXvzrldD0/Lqm8kl5sQQu5ECwTXrsCcUoI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RUK2/WCR; arc=none smtp.client-ip=209.85.208.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RUK2/WCR" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2eeb1ba040aso29986231fa.1 for ; Fri, 09 Aug 2024 08:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723217876; x=1723822676; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=PB1fVkQkmcxX0geIfUn2Aq37PDvmzBF6OHqpyoXeRkI=; b=RUK2/WCRQxHE3EleqS/7RIULQJU4lmYxJ/+9yhFja9jZqpEfVFhHTLTNsWiPhoXRdU GCCwRgeHBj7gSs/wTLxUeDWwUbtDy9noYEfoogCCJmtC/54HjB1shakqER7WchYEPaTn zxSy3lm1VfJSwc24jWSz+30LgdUGcUllWdilvuq/bPWhWWEAV/SYNpf+L1L3bm3QLGdQ 5R87ku/MgSuwbknlUprxO8Du9s3GpobzBQmcBihu6uH8sdupSQCLb8WhBkYU0OYm4XJB TnoPnBFDIB0pkX3/xtkWYUHXaLtClu43+CjP1qLb5FDc0doCln/ICCjs66ZsZfYTeg0n p7qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723217876; x=1723822676; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PB1fVkQkmcxX0geIfUn2Aq37PDvmzBF6OHqpyoXeRkI=; b=n9gpp4AGlLPCshdF1ESifLHSswui6NdPYmSmardaX3pftbrIHHBVtUjoO2XX3b/VYv x+8QaURMuFvoZvVjkNcxBFhsEInthMiV+ft8dkk2VVCK7awcv6k1oW4UYn3riVOIDSpg v1aUAdfO6vfdUS22bTdp4QXqYcQdguslJGuh3rOgxPP7/jyFAeP49LpEHGcmsV9F3dmu nzD1T78cwsuCUbQ1eolvmLKrZAMgfdsgJdhzIYDoAzEecETYmsedL0xaTa0AIGoagqK8 wfQDbGqWrdfuD9Rjity7t1UqacqHtoa3Vv6UWaPKBxD9zhoywGYR0UnHl8aqL0Ji1PJB MC/Q== X-Gm-Message-State: AOJu0YzdspySKj9Dp4Jwbr7qvvoPE3MlCwvwJSBMO9M+MXaLarF2pgcI Z+Wwd0cnuw9UUbGQmrFAdBuxL/LRW5kFq2hQZWZKmx6h20shAO+WfP62eA== X-Google-Smtp-Source: AGHT+IGyWebHWZaVQ2fBBikx4Zr2trqb3vCpgWsbZ9Tv1hfMtODbWKjz7WqkHC1Fr73B2Atj8Rs0iQ== X-Received: by 2002:a05:651c:1549:b0:2f1:922f:8758 with SMTP id 38308e7fff4ca-2f1a6d01e71mr17502891fa.4.1723217875481; Fri, 09 Aug 2024 08:37:55 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c738f18sm79355905e9.13.2024.08.09.08.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 08:37:55 -0700 (PDT) Message-Id: <6cfac5e51f5172d4ee4b610e2e734847038c8fd3.1723217871.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 09 Aug 2024 15:37:50 +0000 Subject: [PATCH v4 2/3] refs: add referent to each_ref_fn Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Kristoffer Haugsbakk , Jeff King , Patrick Steinhardt , =?utf-8?q?Jean-No=C3=ABl?= Avila , Linus Arver , John Cai , John Cai From: John Cai From: John Cai Add a parameter to each_ref_fn so that callers to the ref APIs that use this function as a callback can have acess to the unresolved value of a symbolic ref. Signed-off-by: John Cai --- bisect.c | 3 ++- builtin/bisect.c | 4 +++- builtin/checkout.c | 2 +- builtin/describe.c | 2 +- builtin/fetch.c | 3 ++- builtin/fsck.c | 4 ++-- builtin/gc.c | 1 + builtin/name-rev.c | 2 +- builtin/pack-objects.c | 5 +++-- builtin/receive-pack.c | 2 +- builtin/remote.c | 4 +++- builtin/repack.c | 1 + builtin/replace.c | 1 + builtin/rev-parse.c | 4 ++-- builtin/show-branch.c | 8 ++++---- builtin/show-ref.c | 3 ++- builtin/submodule--helper.c | 1 + builtin/worktree.c | 1 + commit-graph.c | 1 + delta-islands.c | 2 +- fetch-pack.c | 2 ++ help.c | 2 +- http-backend.c | 4 ++-- log-tree.c | 2 +- ls-refs.c | 4 ++-- midx-write.c | 2 +- negotiator/default.c | 2 +- negotiator/skipping.c | 2 +- notes.c | 2 +- object-name.c | 2 +- pseudo-merge.c | 1 + reachable.c | 2 +- ref-filter.c | 4 ++-- reflog.c | 1 + refs.c | 14 +++++++------- refs.h | 2 +- refs/files-backend.c | 2 +- refs/iterator.c | 2 +- remote.c | 4 ++-- replace-object.c | 1 + revision.c | 2 +- server-info.c | 2 +- shallow.c | 2 ++ submodule.c | 2 ++ t/helper/test-ref-store.c | 2 +- upload-pack.c | 8 ++++---- walker.c | 1 + worktree.c | 2 +- 48 files changed, 78 insertions(+), 54 deletions(-) diff --git a/bisect.c b/bisect.c index 135f94ba097..4406fc44cf9 100644 --- a/bisect.c +++ b/bisect.c @@ -448,7 +448,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches, clear_commit_weight(&commit_weight); } -static int register_ref(const char *refname, const struct object_id *oid, +static int register_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb_data UNUSED) { struct strbuf good_prefix = STRBUF_INIT; @@ -1170,6 +1170,7 @@ int estimate_bisect_steps(int all) } static int mark_for_removal(const char *refname, + const char *referent UNUSED, const struct object_id *oid UNUSED, int flag UNUSED, void *cb_data) { diff --git a/builtin/bisect.c b/builtin/bisect.c index dabce9b542b..453a6cccd70 100644 --- a/builtin/bisect.c +++ b/builtin/bisect.c @@ -356,6 +356,7 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd) } static int inc_nr(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid UNUSED, int flag UNUSED, void *cb_data) { @@ -545,7 +546,7 @@ finish: return res; } -static int add_bisect_ref(const char *refname, const struct object_id *oid, +static int add_bisect_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb) { struct add_bisect_ref_data *data = cb; @@ -1162,6 +1163,7 @@ static int bisect_visualize(struct bisect_terms *terms, int argc, } static int get_first_good(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data) { diff --git a/builtin/checkout.c b/builtin/checkout.c index 3cf44b4683a..562778885e1 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1045,7 +1045,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts, report_tracking(new_branch_info); } -static int add_pending_uninteresting_ref(const char *refname, +static int add_pending_uninteresting_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb_data) { diff --git a/builtin/describe.c b/builtin/describe.c index e5287eddf2d..d95a9109eed 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -145,7 +145,7 @@ static void add_to_known_names(const char *path, } } -static int get_name(const char *path, const struct object_id *oid, +static int get_name(const char *path, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) { int is_tag = 0; diff --git a/builtin/fetch.c b/builtin/fetch.c index 693f02b9580..c297569a473 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -286,7 +286,7 @@ static struct refname_hash_entry *refname_hash_add(struct hashmap *map, return ent; } -static int add_one_refname(const char *refname, +static int add_one_refname(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cbdata) { @@ -1464,6 +1464,7 @@ static void set_option(struct transport *transport, const char *name, const char static int add_oid(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb_data) { diff --git a/builtin/fsck.c b/builtin/fsck.c index d13a226c2ed..ef6ee1268bd 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -521,7 +521,7 @@ static int fsck_handle_reflog(const char *logname, void *cb_data) return 0; } -static int fsck_handle_ref(const char *refname, const struct object_id *oid, +static int fsck_handle_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) { struct object *obj; @@ -576,7 +576,7 @@ static void get_default_heads(void) strbuf_worktree_ref(wt, &ref, "HEAD"); fsck_head_link(ref.buf, &head_points_at, &head_oid); if (head_points_at && !is_null_oid(&head_oid)) - fsck_handle_ref(ref.buf, &head_oid, 0, NULL); + fsck_handle_ref(ref.buf, NULL, &head_oid, 0, NULL); strbuf_release(&ref); if (include_reflogs) diff --git a/builtin/gc.c b/builtin/gc.c index 72bac2554fc..65be7c31b33 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -836,6 +836,7 @@ struct cg_auto_data { }; static int dfs_on_ref(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb_data) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 70e9ec4e477..52016f1cf7d 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -337,7 +337,7 @@ static int cmp_by_tag_and_age(const void *a_, const void *b_) return a->taggerdate != b->taggerdate; } -static int name_ref(const char *path, const struct object_id *oid, +static int name_ref(const char *path, const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb_data) { struct object *o = parse_object(the_repository, oid); diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index f395488971f..c481feadbfa 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -771,7 +771,7 @@ static enum write_one_status write_one(struct hashfile *f, return WRITE_ONE_WRITTEN; } -static int mark_tagged(const char *path UNUSED, const struct object_id *oid, +static int mark_tagged(const char *path UNUSED, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) { struct object_id peeled; @@ -3129,7 +3129,7 @@ static void add_tag_chain(const struct object_id *oid) } } -static int add_ref_tag(const char *tag UNUSED, const struct object_id *oid, +static int add_ref_tag(const char *tag UNUSED, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) { struct object_id peeled; @@ -4076,6 +4076,7 @@ static void record_recent_commit(struct commit *commit, void *data UNUSED) } static int mark_bitmap_preferred_tip(const char *refname, + const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *data UNUSED) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 339524ae2a8..6e0f462efbb 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -300,7 +300,7 @@ static void show_ref(const char *path, const struct object_id *oid) } } -static int show_ref_cb(const char *path_full, const struct object_id *oid, +static int show_ref_cb(const char *path_full, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *data) { struct oidset *seen = data; diff --git a/builtin/remote.c b/builtin/remote.c index 08292498bde..9a3db1b0f13 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -543,6 +543,7 @@ struct branches_for_remote { }; static int add_branch_for_removal(const char *refname, + const char *referent UNUSED, const struct object_id *oid UNUSED, int flags UNUSED, void *cb_data) { @@ -585,7 +586,7 @@ struct rename_info { uint32_t symrefs_nr; }; -static int read_remote_branches(const char *refname, +static int read_remote_branches(const char *refname, const char *referent UNUSED, const struct object_id *oid UNUSED, int flags UNUSED, void *cb_data) { @@ -971,6 +972,7 @@ static void free_remote_ref_states(struct ref_states *states) } static int append_ref_to_tracked_list(const char *refname, + const char *referent UNUSED, const struct object_id *oid UNUSED, int flags, void *cb_data) { diff --git a/builtin/repack.c b/builtin/repack.c index f0317fa94ad..d9ea6cecbf9 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -667,6 +667,7 @@ struct midx_snapshot_ref_data { }; static int midx_snapshot_ref_one(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *_data) { diff --git a/builtin/replace.c b/builtin/replace.c index 1ef833c07f5..34cc4672bc1 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -49,6 +49,7 @@ struct show_data { }; static int show_reference(const char *refname, + const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data) { diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 2e64f5bda70..a7084ca157f 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -211,7 +211,7 @@ static int show_default(void) return 0; } -static int show_reference(const char *refname, const struct object_id *oid, +static int show_reference(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) { if (ref_excluded(&ref_excludes, refname)) @@ -220,7 +220,7 @@ static int show_reference(const char *refname, const struct object_id *oid, return 0; } -static int anti_reference(const char *refname, const struct object_id *oid, +static int anti_reference(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) { show_rev(REVERSED, oid, refname); diff --git a/builtin/show-branch.c b/builtin/show-branch.c index d72f4cb98de..3427c1572e5 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -410,7 +410,7 @@ static int append_ref(const char *refname, const struct object_id *oid, return 0; } -static int append_head_ref(const char *refname, const struct object_id *oid, +static int append_head_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) { struct object_id tmp; @@ -425,7 +425,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid, return append_ref(refname + ofs, oid, 0); } -static int append_remote_ref(const char *refname, const struct object_id *oid, +static int append_remote_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) { struct object_id tmp; @@ -451,7 +451,7 @@ static int append_tag_ref(const char *refname, const struct object_id *oid, static const char *match_ref_pattern = NULL; static int match_ref_slash = 0; -static int append_matching_ref(const char *refname, const struct object_id *oid, +static int append_matching_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag, void *cb_data) { /* we want to allow pattern hold/ to show all @@ -468,7 +468,7 @@ static int append_matching_ref(const char *refname, const struct object_id *oid, if (wildmatch(match_ref_pattern, tail, 0)) return 0; if (starts_with(refname, "refs/heads/")) - return append_head_ref(refname, oid, flag, cb_data); + return append_head_ref(refname, NULL, oid, flag, cb_data); if (starts_with(refname, "refs/tags/")) return append_tag_ref(refname, oid, flag, cb_data); return append_ref(refname, oid, 0); diff --git a/builtin/show-ref.c b/builtin/show-ref.c index 839a5c29f31..04e0db707c6 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -63,7 +63,7 @@ struct show_ref_data { int show_head; }; -static int show_ref(const char *refname, const struct object_id *oid, +static int show_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cbdata) { struct show_ref_data *data = cbdata; @@ -97,6 +97,7 @@ match: } static int add_existing(const char *refname, + const char *referent UNUSED, const struct object_id *oid UNUSED, int flag UNUSED, void *cbdata) { diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 880ab4456ee..1cdcc465b1c 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -609,6 +609,7 @@ static void print_status(unsigned int flags, char state, const char *path, } static int handle_submodule_head_ref(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb_data) diff --git a/builtin/worktree.c b/builtin/worktree.c index 1d51e54fcdc..2e16218c655 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -626,6 +626,7 @@ static void print_preparing_worktree_line(int detach, * Returns 0 on failure and non-zero on success. */ static int first_valid_ref(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid UNUSED, int flags UNUSED, void *cb_data UNUSED) diff --git a/commit-graph.c b/commit-graph.c index 79b0e72cc42..aa6e08eb39c 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -1847,6 +1847,7 @@ struct refs_cb_data { }; static int add_ref_to_set(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb_data) { diff --git a/delta-islands.c b/delta-islands.c index ffe1ca28144..84435512593 100644 --- a/delta-islands.c +++ b/delta-islands.c @@ -390,7 +390,7 @@ static void add_ref_to_island(kh_str_t *remote_islands, const char *island_name, rl->hash += sha_core; } -static int find_island_for_ref(const char *refname, const struct object_id *oid, +static int find_island_for_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb) { struct island_load_data *ild = cb; diff --git a/fetch-pack.c b/fetch-pack.c index 732511604b1..58b4581ad80 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -183,6 +183,7 @@ static int rev_list_insert_ref(struct fetch_negotiator *negotiator, } static int rev_list_insert_ref_oid(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data) @@ -610,6 +611,7 @@ static int mark_complete(const struct object_id *oid) } static int mark_complete_oid(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) diff --git a/help.c b/help.c index a6b4d3b1ebd..c03863f2265 100644 --- a/help.c +++ b/help.c @@ -804,7 +804,7 @@ struct similar_ref_cb { struct string_list *similar_refs; }; -static int append_similar_ref(const char *refname, +static int append_similar_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid UNUSED, int flags UNUSED, void *cb_data) { diff --git a/http-backend.c b/http-backend.c index 461424972b6..79ce097359b 100644 --- a/http-backend.c +++ b/http-backend.c @@ -512,7 +512,7 @@ static void run_service(const char **argv, int buffer_input) exit(1); } -static int show_text_ref(const char *name, const struct object_id *oid, +static int show_text_ref(const char *name, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data) { const char *name_nons = strip_namespace(name); @@ -568,7 +568,7 @@ static void get_info_refs(struct strbuf *hdr, char *arg UNUSED) strbuf_release(&buf); } -static int show_head_ref(const char *refname, const struct object_id *oid, +static int show_head_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag, void *cb_data) { struct strbuf *buf = cb_data; diff --git a/log-tree.c b/log-tree.c index 52feec4356a..40306434556 100644 --- a/log-tree.c +++ b/log-tree.c @@ -145,7 +145,7 @@ static int ref_filter_match(const char *refname, return 1; } -static int add_ref_decoration(const char *refname, const struct object_id *oid, +static int add_ref_decoration(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb_data) { diff --git a/ls-refs.c b/ls-refs.c index 2dd925b43d0..c824aea7146 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -77,7 +77,7 @@ struct ls_refs_data { unsigned unborn : 1; }; -static int send_ref(const char *refname, const struct object_id *oid, +static int send_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag, void *cb_data) { struct ls_refs_data *data = cb_data; @@ -135,7 +135,7 @@ static void send_possibly_unborn_head(struct ls_refs_data *data) oid_is_null = is_null_oid(&oid); if (!oid_is_null || (data->unborn && data->symrefs && (flag & REF_ISSYMREF))) - send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flag, data); + send_ref(namespaced.buf, NULL, oid_is_null ? NULL : &oid, flag, data); strbuf_release(&namespaced); } diff --git a/midx-write.c b/midx-write.c index 478b42e7209..56d1717f9f1 100644 --- a/midx-write.c +++ b/midx-write.c @@ -655,7 +655,7 @@ static void prepare_midx_packing_data(struct packing_data *pdata, trace2_region_leave("midx", "prepare_midx_packing_data", the_repository); } -static int add_ref_to_pending(const char *refname, +static int add_ref_to_pending(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag, void *cb_data) { diff --git a/negotiator/default.c b/negotiator/default.c index e3fa5c33249..c479da9b091 100644 --- a/negotiator/default.c +++ b/negotiator/default.c @@ -38,7 +38,7 @@ static void rev_list_push(struct negotiation_state *ns, } } -static int clear_marks(const char *refname, const struct object_id *oid, +static int clear_marks(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) { diff --git a/negotiator/skipping.c b/negotiator/skipping.c index f109928ad0b..f65d47858b4 100644 --- a/negotiator/skipping.c +++ b/negotiator/skipping.c @@ -75,7 +75,7 @@ static struct entry *rev_list_push(struct data *data, struct commit *commit, int return entry; } -static int clear_marks(const char *refname, const struct object_id *oid, +static int clear_marks(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) { diff --git a/notes.c b/notes.c index 1ba6412aae8..da42df282d5 100644 --- a/notes.c +++ b/notes.c @@ -932,7 +932,7 @@ out: return ret; } -static int string_list_add_one_ref(const char *refname, +static int string_list_add_one_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid UNUSED, int flag UNUSED, void *cb) { diff --git a/object-name.c b/object-name.c index 527b853ac45..7cca43020f2 100644 --- a/object-name.c +++ b/object-name.c @@ -1365,7 +1365,7 @@ struct handle_one_ref_cb { struct commit_list **list; }; -static int handle_one_ref(const char *path, const struct object_id *oid, +static int handle_one_ref(const char *path, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data) { diff --git a/pseudo-merge.c b/pseudo-merge.c index f0fde13c471..77a83b9c5ce 100644 --- a/pseudo-merge.c +++ b/pseudo-merge.c @@ -201,6 +201,7 @@ void load_pseudo_merges_from_config(struct string_list *list) } static int find_pseudo_merge_group_for_ref(const char *refname, + const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *_data) diff --git a/reachable.c b/reachable.c index 46613a6bb6f..3e9b3dd0a46 100644 --- a/reachable.c +++ b/reachable.c @@ -79,7 +79,7 @@ static void add_rebase_files(struct rev_info *revs) free_worktrees(worktrees); } -static int add_one_ref(const char *path, const struct object_id *oid, +static int add_one_ref(const char *path, const char *referent UNUSED, const struct object_id *oid, int flag, void *cb_data) { struct rev_info *revs = (struct rev_info *)cb_data; diff --git a/ref-filter.c b/ref-filter.c index 8c5e673fc0a..39997890feb 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -2865,7 +2865,7 @@ struct ref_filter_cbdata { * A call-back given to for_each_ref(). Filter refs and keep them for * later object processing. */ -static int filter_one(const char *refname, const struct object_id *oid, int flag, void *cb_data) +static int filter_one(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag, void *cb_data) { struct ref_filter_cbdata *ref_cbdata = cb_data; struct ref_array_item *ref; @@ -2900,7 +2900,7 @@ struct ref_filter_and_format_cbdata { } internal; }; -static int filter_and_format_one(const char *refname, const struct object_id *oid, int flag, void *cb_data) +static int filter_and_format_one(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag, void *cb_data) { struct ref_filter_and_format_cbdata *ref_cbdata = cb_data; struct ref_array_item *ref; diff --git a/reflog.c b/reflog.c index 5ca944529b3..d592c1cfb56 100644 --- a/reflog.c +++ b/reflog.c @@ -300,6 +300,7 @@ int should_expire_reflog_ent_verbose(struct object_id *ooid, } static int push_tip_to_list(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flags, void *cb_data) { diff --git a/refs.c b/refs.c index bb90a188758..0a5c12cf16b 100644 --- a/refs.c +++ b/refs.c @@ -414,7 +414,7 @@ int refs_ref_exists(struct ref_store *refs, const char *refname) NULL, NULL); } -static int for_each_filter_refs(const char *refname, +static int for_each_filter_refs(const char *refname, const char *referent, const struct object_id *oid, int flags, void *data) { @@ -424,7 +424,7 @@ static int for_each_filter_refs(const char *refname, return 0; if (filter->prefix) skip_prefix(refname, filter->prefix, &refname); - return filter->fn(refname, oid, flags, filter->cb_data); + return filter->fn(refname, referent, oid, flags, filter->cb_data); } struct warn_if_dangling_data { @@ -435,7 +435,7 @@ struct warn_if_dangling_data { const char *msg_fmt; }; -static int warn_if_dangling_symref(const char *refname, +static int warn_if_dangling_symref(const char *refname, const char *referent UNUSED, const struct object_id *oid UNUSED, int flags, void *cb_data) { @@ -506,7 +506,7 @@ int refs_head_ref_namespaced(struct ref_store *refs, each_ref_fn fn, void *cb_da strbuf_addf(&buf, "%sHEAD", get_git_namespace()); if (!refs_read_ref_full(refs, buf.buf, RESOLVE_REF_READING, &oid, &flag)) - ret = fn(buf.buf, &oid, flag, cb_data); + ret = fn(buf.buf, NULL, &oid, flag, cb_data); strbuf_release(&buf); return ret; @@ -1547,7 +1547,7 @@ int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data) if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING, &oid, &flag)) - return fn("HEAD", &oid, flag, cb_data); + return fn("HEAD", NULL, &oid, flag, cb_data); return 0; } @@ -2387,7 +2387,7 @@ struct do_for_each_reflog_help { void *cb_data; }; -static int do_for_each_reflog_helper(const char *refname, +static int do_for_each_reflog_helper(const char *refname, const char *referent, const struct object_id *oid UNUSED, int flags, void *cb_data) @@ -2593,7 +2593,7 @@ struct migration_data { struct strbuf *errbuf; }; -static int migrate_one_ref(const char *refname, const struct object_id *oid, +static int migrate_one_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flags, void *cb_data) { struct migration_data *data = cb_data; diff --git a/refs.h b/refs.h index 0ecba21b4a7..158e0a12197 100644 --- a/refs.h +++ b/refs.h @@ -298,7 +298,7 @@ struct ref_transaction; * arguments is only guaranteed to be valid for the duration of a * single callback invocation. */ -typedef int each_ref_fn(const char *refname, +typedef int each_ref_fn(const char *refname, const char *referent, const struct object_id *oid, int flags, void *cb_data); /* diff --git a/refs/files-backend.c b/refs/files-backend.c index 210adf644fa..94d1ed0e1c7 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3044,7 +3044,7 @@ static int files_transaction_abort(struct ref_store *ref_store, return 0; } -static int ref_present(const char *refname, +static int ref_present(const char *refname, const char *referent UNUSED, const struct object_id *oid UNUSED, int flags UNUSED, void *cb_data) diff --git a/refs/iterator.c b/refs/iterator.c index 75fbe5d72ab..8e999d81fc6 100644 --- a/refs/iterator.c +++ b/refs/iterator.c @@ -450,7 +450,7 @@ int do_for_each_ref_iterator(struct ref_iterator *iter, current_ref_iter = iter; while ((ok = ref_iterator_advance(iter)) == ITER_OK) { - retval = fn(iter->refname, iter->oid, iter->flags, cb_data); + retval = fn(iter->refname, iter->referent, iter->oid, iter->flags, cb_data); if (retval) { /* * If ref_iterator_abort() returns ITER_ERROR, diff --git a/remote.c b/remote.c index f43cf5e7a4d..4a1269a47ab 100644 --- a/remote.c +++ b/remote.c @@ -2354,7 +2354,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb, return 1; } -static int one_local_ref(const char *refname, const struct object_id *oid, +static int one_local_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data) { @@ -2439,7 +2439,7 @@ struct stale_heads_info { struct refspec *rs; }; -static int get_stale_heads_cb(const char *refname, const struct object_id *oid, +static int get_stale_heads_cb(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flags, void *cb_data) { struct stale_heads_info *info = cb_data; diff --git a/replace-object.c b/replace-object.c index 59252d565ef..9a3cdd809a9 100644 --- a/replace-object.c +++ b/replace-object.c @@ -9,6 +9,7 @@ #include "commit.h" static int register_replace_ref(const char *refname, + const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data) diff --git a/revision.c b/revision.c index 1c0192f5225..6b33bd814f7 100644 --- a/revision.c +++ b/revision.c @@ -1648,7 +1648,7 @@ struct all_refs_cb { struct worktree *wt; }; -static int handle_one_ref(const char *path, const struct object_id *oid, +static int handle_one_ref(const char *path, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data) { diff --git a/server-info.c b/server-info.c index f61296a60d0..1508fa6f825 100644 --- a/server-info.c +++ b/server-info.c @@ -147,7 +147,7 @@ out: return ret; } -static int add_info_ref(const char *path, const struct object_id *oid, +static int add_info_ref(const char *path, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data) { diff --git a/shallow.c b/shallow.c index 31a6ca40fe2..b8cd051e3b6 100644 --- a/shallow.c +++ b/shallow.c @@ -612,6 +612,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid, } static int mark_uninteresting(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb_data UNUSED) @@ -727,6 +728,7 @@ struct commit_array { }; static int add_ref(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *cb_data) diff --git a/submodule.c b/submodule.c index ab99a302530..7c0f5db861d 100644 --- a/submodule.c +++ b/submodule.c @@ -953,6 +953,7 @@ static void free_submodules_data(struct string_list *submodules) } static int has_remote(const char *refname UNUSED, + const char *referent UNUSED, const struct object_id *oid UNUSED, int flags UNUSED, void *cb_data UNUSED) { @@ -1273,6 +1274,7 @@ int push_unpushed_submodules(struct repository *r, } static int append_oid_to_array(const char *ref UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flags UNUSED, void *data) { diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 637b8b294e9..65346dee551 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -156,7 +156,7 @@ static int cmd_rename_ref(struct ref_store *refs, const char **argv) return refs_rename_ref(refs, oldref, newref, logmsg); } -static int each_ref(const char *refname, const struct object_id *oid, +static int each_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flags, void *cb_data UNUSED) { printf("%s %s 0x%x\n", oid_to_hex(oid), refname, flags); diff --git a/upload-pack.c b/upload-pack.c index 0052c6a4dce..f03ba3e98be 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -857,7 +857,7 @@ static void send_unshallow(struct upload_pack_data *data) } } -static int check_ref(const char *refname_full, const struct object_id *oid, +static int check_ref(const char *refname_full, const char *referent UNUSED, const struct object_id *oid, int flag, void *cb_data); static void deepen(struct upload_pack_data *data, int depth) { @@ -1208,7 +1208,7 @@ static int mark_our_ref(const char *refname, const char *refname_full, return 0; } -static int check_ref(const char *refname_full, const struct object_id *oid, +static int check_ref(const char *refname_full, const char *referent UNUSED,const struct object_id *oid, int flag UNUSED, void *cb_data) { const char *refname = strip_namespace(refname_full); @@ -1276,14 +1276,14 @@ static void write_v0_ref(struct upload_pack_data *data, return; } -static int send_ref(const char *refname, const struct object_id *oid, +static int send_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data) { write_v0_ref(cb_data, refname, strip_namespace(refname), oid); return 0; } -static int find_symref(const char *refname, +static int find_symref(const char *refname, const char *referent UNUSED, const struct object_id *oid UNUSED, int flag, void *cb_data) { diff --git a/walker.c b/walker.c index 0fafdc97cf1..807a7a38813 100644 --- a/walker.c +++ b/walker.c @@ -221,6 +221,7 @@ static int interpret_target(struct walker *walker, char *target, struct object_i } static int mark_complete(const char *path UNUSED, + const char *referent UNUSED, const struct object_id *oid, int flag UNUSED, void *cb_data UNUSED) diff --git a/worktree.c b/worktree.c index f3c4c8ec54d..fd05f3741c6 100644 --- a/worktree.c +++ b/worktree.c @@ -546,7 +546,7 @@ int other_head_refs(each_ref_fn fn, void *cb_data) refname.buf, RESOLVE_REF_READING, &oid, &flag)) - ret = fn(refname.buf, &oid, flag, cb_data); + ret = fn(refname.buf, NULL, &oid, flag, cb_data); if (ret) break; } From patchwork Fri Aug 9 15:37:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 13758898 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 476731991DC for ; Fri, 9 Aug 2024 15:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723217881; cv=none; b=KI+6I448BkzU+vBxAftVJQjxhHiLiArhJGbCDWVSe91SNe6yX3ydZiWAun6I0wl0x6VHhP7MBpohYKg5ow9eUpa6EWX31ZYM8hrHYDchaicvG1M5TXKDfsSwzD7Bd9mgn0XhV9CRptUS7XvOUBcS3FYxxOUyvXIs7KMJnA2sAZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723217881; c=relaxed/simple; bh=a2yIn2+IzTEn3yyzmvLR2PkJdBxUyySG7Vm1F9Gux50=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=Ouppzir92kY72wKnmVIxNcLaLgn4aJmloJk+KFYx1TAnfbOjJr8yP8c4Sk+omIOejugedbUudx+M81g6OvjF/XHt3CWTr0NeRofFjFCnoG9HBlohrb3HD06KcRrY/w7doVVCMD9vEa9BzT51Zje38M9bTLMjaWTSrFy7Tnav2k8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mJktOoFR; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mJktOoFR" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-367ab76d5e1so1059885f8f.3 for ; Fri, 09 Aug 2024 08:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723217877; x=1723822677; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=J+jVgXCXFRNurdNyelC4oTNBDe8r9mXUPEwVy6OJzg0=; b=mJktOoFRH6zpMYIMkzYav10s5BcdeQmu2lxacsi0UstHhBMiSZdH6lGVC5uT6ppv8H vnhA7WQfSYGUGzU8zIeOpL3Dv+oy4hX9zLsbutYFGIfJCcVdnufWKRycMsCbJwoj4y3+ bUIkiyfp4akAVhFwygUYIdVNHW057asRNkB0Xne5tI0OFCaRf04f2xH80LHfooJC0czd uxkSOYaQuzOvyM3U+jabd7Bo69iytuBwhSsdjpTo6LH7pwSJDNrNV9gPQU6N6I9y63BJ 373BbS3oUcrJ7URfp79fcdsS9uV2IR/8rsBDMtgdEm4O/YFyBBuKXxbNkgo0gM8NU4Z4 1jjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723217877; x=1723822677; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J+jVgXCXFRNurdNyelC4oTNBDe8r9mXUPEwVy6OJzg0=; b=AfwT2Wzp9F8x9L5I7+Es5YBjHXEx10/Nbhr659WKJcb4WzIVhuo1juEEchgpqLn82t gI07ivdD/RH7UKsWFCDsKlyTknvWVWx4Fju185cSiC9ruOyIMjXFqbTGA8gcSfLtPWtl gQa8WEDwr0FwbL3oYk9fuRAUABbWOoLG2kUPOzWT5I+H1I8u+5JGdOTxLEZ1aCzY6eFi 3gLV8EpuXPqK7NwvNsuoUmfsa0X5M8B7KUHTx1S8CVMJO+wk9RD2D8CX5YwdY70RAnGB GBfs30xRRfnx2CPf7yWIlNFkEvcSBShqzpdEHItr0EnsBnWMV2/Q2udZBuz1YmbjF9s+ sdwA== X-Gm-Message-State: AOJu0YymUlBPI2U1tLt67TRIfFGfl4S8m7/xb8Br37Q0394/cbbTp+wq 48RMr5g3W6IgubKlbz/Ce5ST0hL2FJ5cqJfZIjNkRrAyqx/u73fZXMbvpQ== X-Google-Smtp-Source: AGHT+IGPICwKRlCNMPIIpb8as0Z9tLI/sGGjo5dcJp+sltIPmmG0/ZoOv8ad/c+LdKtC10u57KwwGw== X-Received: by 2002:a05:6000:4022:b0:368:4bc0:9211 with SMTP id ffacd0b85a97d-36d5fb92ddemr1541003f8f.17.1723217877206; Fri, 09 Aug 2024 08:37:57 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d2716cc62sm5587023f8f.32.2024.08.09.08.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 08:37:56 -0700 (PDT) Message-Id: <9f609f4d0f50758cd32b172e6e2ed7b3e71cf29f.1723217872.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 09 Aug 2024 15:37:51 +0000 Subject: [PATCH v4 3/3] ref-filter: populate symref from iterator Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Kristoffer Haugsbakk , Jeff King , Patrick Steinhardt , =?utf-8?q?Jean-No=C3=ABl?= Avila , Linus Arver , John Cai , John Cai From: John Cai From: John Cai With a previous commit, the reference the symbolic ref points to is saved in the ref iterator records. Instead of making a separate call to resolve_refdup() each time, we can just populate the ref_array_item with the value from the iterator. Signed-off-by: John Cai --- ref-filter.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ref-filter.c b/ref-filter.c index 39997890feb..4d1f3ff3d23 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -2343,6 +2343,12 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err) CALLOC_ARRAY(ref->value, used_atom_cnt); + /** + * NEEDSWORK: The following code might be unncessary if all codepaths + * that call populate_value() populates the symref member of ref_array_item + * like in apply_ref_filter(). Currently pretty_print_ref() is the only codepath + * that calls populate_value() without first populating symref. + */ if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) { ref->symref = refs_resolve_refdup(get_main_ref_store(the_repository), ref->refname, @@ -2783,7 +2789,7 @@ static int filter_ref_kind(struct ref_filter *filter, const char *refname) return ref_kind_from_refname(refname); } -static struct ref_array_item *apply_ref_filter(const char *refname, const struct object_id *oid, +static struct ref_array_item *apply_ref_filter(const char *refname, const char *referent, const struct object_id *oid, int flag, struct ref_filter *filter) { struct ref_array_item *ref; @@ -2852,6 +2858,7 @@ static struct ref_array_item *apply_ref_filter(const char *refname, const struct ref->commit = commit; ref->flag = flag; ref->kind = kind; + ref->symref = xstrdup_or_null(referent); return ref; } @@ -2865,12 +2872,12 @@ struct ref_filter_cbdata { * A call-back given to for_each_ref(). Filter refs and keep them for * later object processing. */ -static int filter_one(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag, void *cb_data) +static int filter_one(const char *refname, const char *referent, const struct object_id *oid, int flag, void *cb_data) { struct ref_filter_cbdata *ref_cbdata = cb_data; struct ref_array_item *ref; - ref = apply_ref_filter(refname, oid, flag, ref_cbdata->filter); + ref = apply_ref_filter(refname, referent, oid, flag, ref_cbdata->filter); if (ref) ref_array_append(ref_cbdata->array, ref); @@ -2900,13 +2907,13 @@ struct ref_filter_and_format_cbdata { } internal; }; -static int filter_and_format_one(const char *refname, const char *referent UNUSED, const struct object_id *oid, int flag, void *cb_data) +static int filter_and_format_one(const char *refname, const char *referent, const struct object_id *oid, int flag, void *cb_data) { struct ref_filter_and_format_cbdata *ref_cbdata = cb_data; struct ref_array_item *ref; struct strbuf output = STRBUF_INIT, err = STRBUF_INIT; - ref = apply_ref_filter(refname, oid, flag, ref_cbdata->filter); + ref = apply_ref_filter(refname, referent, oid, flag, ref_cbdata->filter); if (!ref) return 0;