git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] remote: pass NULL to read_ref_full() because object ID is not needed
@ 2019-12-11 18:46 René Scharfe
  2019-12-11 18:57 ` Derrick Stolee
  0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2019-12-11 18:46 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano

read_ref_full() wraps refs_read_ref_full(), which in turn wraps
refs_resolve_ref_unsafe(), which handles a NULL oid pointer of callers
not interested in the resolved object ID.  Make use of that feature to
document that mv() is such a caller.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 builtin/remote.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/remote.c b/builtin/remote.c
index 5591cef775..96bbe828fe 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -693,9 +693,8 @@ static int mv(int argc, const char **argv)
 	for (i = 0; i < remote_branches.nr; i++) {
 		struct string_list_item *item = remote_branches.items + i;
 		int flag = 0;
-		struct object_id oid;

-		read_ref_full(item->string, RESOLVE_REF_READING, &oid, &flag);
+		read_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag);
 		if (!(flag & REF_ISSYMREF))
 			continue;
 		if (delete_ref(NULL, item->string, NULL, REF_NO_DEREF))
--
2.24.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] remote: pass NULL to read_ref_full() because object ID is not needed
  2019-12-11 18:46 [PATCH] remote: pass NULL to read_ref_full() because object ID is not needed René Scharfe
@ 2019-12-11 18:57 ` Derrick Stolee
  0 siblings, 0 replies; 2+ messages in thread
From: Derrick Stolee @ 2019-12-11 18:57 UTC (permalink / raw)
  To: René Scharfe, Git Mailing List; +Cc: Junio C Hamano

On 12/11/2019 1:46 PM, René Scharfe wrote:
> read_ref_full() wraps refs_read_ref_full(), which in turn wraps
> refs_resolve_ref_unsafe(), which handles a NULL oid pointer of callers
> not interested in the resolved object ID.  Make use of that feature to
> document that mv() is such a caller.

Double-checking the code shows this in refs_resolve_ref_unsafe():

        if (!oid)
                oid = &unused_oid;

where unused_oid is a local struct. Unfortunate that the correct code
change doesn't get any performance benefit for sending this message
of "I don't need this value".

LGTM.

-Stolee

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-11 18:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 18:46 [PATCH] remote: pass NULL to read_ref_full() because object ID is not needed René Scharfe
2019-12-11 18:57 ` Derrick Stolee

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).