remote: pass NULL to read_ref_full() because object ID is not needed
diff mbox series

Message ID 24fc1649-d80c-cc4b-8268-a7833812d39c@web.de
State New
Headers show
Series
  • remote: pass NULL to read_ref_full() because object ID is not needed
Related show

Commit Message

René Scharfe Dec. 11, 2019, 6:46 p.m. UTC
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(-)

--
2.24.1

Comments

Derrick Stolee Dec. 11, 2019, 6:57 p.m. UTC | #1
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

Patch
diff mbox series

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))