{"thread":{"id":"52432","subject":"[PATCH] remote: pass NULL to read_ref_full() because object ID is not needed","startedAt":"2019-12-11T18:46:43Z","lastAt":"2019-12-11T18:57:51Z","messageCount":2,"participants":["René Scharfe","Derrick Stolee"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"387963","messageId":"24fc1649-d80c-cc4b-8268-a7833812d39c@web.de","threadId":"52432","inReplyTo":null,"subject":"[PATCH] remote: pass NULL to read_ref_full() because object ID is not needed","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-12-11T18:46:37Z","receivedAt":"2019-12-11T18:46:43Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"read_ref_full() wraps refs_read_ref_full(), which in turn wraps\nrefs_resolve_ref_unsafe(), which handles a NULL oid pointer of callers\nnot interested in the resolved object ID.  Make use of that feature to\ndocument that mv() is such a caller.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n builtin/remote.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 5591cef775..96bbe828fe 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -693,9 +693,8 @@ static int mv(int argc, const char **argv)\n \tfor (i = 0; i < remote_branches.nr; i++) {\n \t\tstruct string_list_item *item = remote_branches.items + i;\n \t\tint flag = 0;\n-\t\tstruct object_id oid;\n\n-\t\tread_ref_full(item->string, RESOLVE_REF_READING, &oid, &flag);\n+\t\tread_ref_full(item->string, RESOLVE_REF_READING, NULL, &flag);\n \t\tif (!(flag & REF_ISSYMREF))\n \t\t\tcontinue;\n \t\tif (delete_ref(NULL, item->string, NULL, REF_NO_DEREF))\n--\n2.24.1\n"},{"id":"387964","messageId":"a1bfb55c-21dd-12e6-186b-44c1873d1c52@gmail.com","threadId":"52432","inReplyTo":"24fc1649-d80c-cc4b-8268-a7833812d39c@web.de","subject":"Re: [PATCH] remote: pass NULL to read_ref_full() because object ID is not needed","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2019-12-11T18:57:48Z","receivedAt":"2019-12-11T18:57:51Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 12/11/2019 1:46 PM, René Scharfe wrote:\n> read_ref_full() wraps refs_read_ref_full(), which in turn wraps\n> refs_resolve_ref_unsafe(), which handles a NULL oid pointer of callers\n> not interested in the resolved object ID.  Make use of that feature to\n> document that mv() is such a caller.\n\nDouble-checking the code shows this in refs_resolve_ref_unsafe():\n\n        if (!oid)\n                oid = &unused_oid;\n\nwhere unused_oid is a local struct. Unfortunate that the correct code\nchange doesn't get any performance benefit for sending this message\nof \"I don't need this value\".\n\nLGTM.\n\n-Stolee\n"}]}