All of lore.kernel.org
 help / color / mirror / Atom feed
From: "John Cai via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Phillip Wood" <phillip.wood123@gmail.com>,
	"Kristoffer Haugsbakk" <code@khaugsbakk.name>,
	"Jeff King" <peff@peff.net>, "Patrick Steinhardt" <ps@pks.im>,
	"Jean-Noël Avila" <avila.jn@gmail.com>,
	"John Cai" <johncai86@gmail.com>,
	"John Cai" <johncai86@gmail.com>
Subject: [PATCH v2 2/3] refs: add referent to each_repo_ref_fn
Date: Mon, 08 Apr 2024 17:38:12 +0000	[thread overview]
Message-ID: <b60e78560e0d8e9b73090fad7b1b91eee19abf75.1712597893.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1684.v2.git.git.1712597893.gitgitgadget@gmail.com>

From: John Cai <johncai86@gmail.com>

There is no way for callers of the refs api functions that use iterators
to get a hold of a direct value of a symbolic ref before its resolved in
the callback functions, as either each_ref_fn nor each_repo_ref_fn have
an argument for this.

This did not matter since the iterators did not hold onto the direct
value of a reference anyway. But, the previous commit started to save
the value of the direct reference in the iterator.

Add an argument to each_repo_ref_fn that gets passed the direct
value of a reference.

Signed-off-by: John Cai <johncai86@gmail.com>
---
 builtin/replace.c | 1 +
 refs.c            | 2 ++
 refs.h            | 1 +
 refs/iterator.c   | 2 +-
 replace-object.c  | 1 +
 5 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/builtin/replace.c b/builtin/replace.c
index da59600ad22..36fa58db82c 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -48,6 +48,7 @@ struct show_data {
 };
 
 static int show_reference(struct repository *r, const char *refname,
+			  const char *referent UNUSED,
 			  const struct object_id *oid,
 			  int flag UNUSED, void *cb_data)
 {
diff --git a/refs.c b/refs.c
index b87a680249e..77ae38ea214 100644
--- a/refs.c
+++ b/refs.c
@@ -1664,6 +1664,7 @@ struct do_for_each_ref_help {
 
 static int do_for_each_ref_helper(struct repository *r UNUSED,
 				  const char *refname,
+				  const char *referent,
 				  const struct object_id *oid,
 				  int flags,
 				  void *cb_data)
@@ -2565,6 +2566,7 @@ struct do_for_each_reflog_help {
 
 static int do_for_each_reflog_helper(struct repository *r UNUSED,
 				     const char *refname,
+				     const char *referent,
 				     const struct object_id *oid UNUSED,
 				     int flags,
 				     void *cb_data)
diff --git a/refs.h b/refs.h
index 2e740c692ac..23e5aaba2e9 100644
--- a/refs.h
+++ b/refs.h
@@ -311,6 +311,7 @@ typedef int each_ref_fn(const char *refname,
  */
 typedef int each_repo_ref_fn(struct repository *r,
 			     const char *refname,
+			     const char *referent,
 			     const struct object_id *oid,
 			     int flags,
 			     void *cb_data);
diff --git a/refs/iterator.c b/refs/iterator.c
index 26ca6f645ee..7e04d8427a9 100644
--- a/refs/iterator.c
+++ b/refs/iterator.c
@@ -449,7 +449,7 @@ int do_for_each_repo_ref_iterator(struct repository *r, struct ref_iterator *ite
 
 	current_ref_iter = iter;
 	while ((ok = ref_iterator_advance(iter)) == ITER_OK) {
-		retval = fn(r, iter->refname, iter->oid, iter->flags, cb_data);
+		retval = fn(r, iter->refname, iter->referent, iter->oid, iter->flags, cb_data);
 		if (retval) {
 			/*
 			 * If ref_iterator_abort() returns ITER_ERROR,
diff --git a/replace-object.c b/replace-object.c
index 523215589de..32d90f35327 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -10,6 +10,7 @@
 
 static int register_replace_ref(struct repository *r,
 				const char *refname,
+				const char *referent UNUSED,
 				const struct object_id *oid,
 				int flag UNUSED,
 				void *cb_data UNUSED)
-- 
gitgitgadget


  parent reply	other threads:[~2024-04-08 17:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 22:51 [PATCH] show-ref: add --unresolved option John Cai via GitGitGadget
2024-03-04 23:23 ` Junio C Hamano
2024-03-05 20:56   ` John Cai
2024-03-05 21:29     ` Junio C Hamano
2024-03-05 15:30 ` Phillip Wood
2024-03-05 17:01   ` Kristoffer Haugsbakk
2024-03-06  0:33   ` Jeff King
2024-03-06  2:19     ` Junio C Hamano
2024-03-06  0:41 ` Jeff King
2024-03-06  7:31   ` Patrick Steinhardt
2024-03-06  7:51     ` Jeff King
2024-03-06 16:48       ` Junio C Hamano
2024-03-06  9:36 ` Jean-Noël Avila
2024-04-08 17:38 ` [PATCH v2 0/3] show-ref: add --symbolic-name option John Cai via GitGitGadget
2024-04-08 17:38   ` [PATCH v2 1/3] refs: keep track of unresolved reference value in iterator John Cai via GitGitGadget
2024-04-08 23:02     ` Junio C Hamano
2024-04-09 20:29       ` John Cai
2024-04-10  6:52     ` Patrick Steinhardt
2024-04-10 15:26       ` Junio C Hamano
2024-04-11  9:11         ` Patrick Steinhardt
2024-04-08 17:38   ` John Cai via GitGitGadget [this message]
2024-04-08 17:38   ` [PATCH v2 3/3] show-ref: add --symbolic-name option John Cai via GitGitGadget
2024-04-09 15:25     ` Phillip Wood
2024-04-11 19:57       ` John Cai
2024-04-12  9:37         ` phillip.wood123
2024-04-10  6:53     ` Patrick Steinhardt
2024-04-10 15:27       ` Junio C Hamano
2024-04-12 15:23       ` John Cai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b60e78560e0d8e9b73090fad7b1b91eee19abf75.1712597893.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=avila.jn@gmail.com \
    --cc=code@khaugsbakk.name \
    --cc=git@vger.kernel.org \
    --cc=johncai86@gmail.com \
    --cc=peff@peff.net \
    --cc=phillip.wood123@gmail.com \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.