# [PATCH] refs: pass NULL to refs_read_ref_full() because object ID is not needed

2 messages from 2019-12-11 to 2019-12-11. Participants: René Scharfe, Derrick Stolee.
Thread: https://gitlist.dev/t/52430

## René Scharfe, 2019-12-11 18:46

Subject: [PATCH] refs: pass NULL to refs_read_ref_full() because object ID is not needed
Message-ID: <a762958e-324b-f9a5-96e4-fab0b4b91df8@web.de>
URL: https://gitlist.dev/e/a762958e-324b-f9a5-96e4-fab0b4b91df8%40web.de

```
refs_read_ref_full() wraps refs_resolve_ref_unsafe(), which handles a
NULL oid pointer of callers not interested in the resolved object ID.
Pass NULL from files_copy_or_rename_ref() to clarify that it is one
such caller.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 refs/files-backend.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/refs/files-backend.c b/refs/files-backend.c
index d60767ab73..0ea66a28b6 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1327,7 +1327,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
 {
 	struct files_ref_store *refs =
 		files_downcast(ref_store, REF_STORE_WRITE, "rename_ref");
-	struct object_id oid, orig_oid;
+	struct object_id orig_oid;
 	int flag = 0, logmoved = 0;
 	struct ref_lock *lock;
 	struct stat loginfo;
@@ -1395,7 +1395,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
 	 */
 	if (!copy && !refs_read_ref_full(&refs->base, newrefname,
 				RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
-				&oid, NULL) &&
+				NULL, NULL) &&
 	    refs_delete_ref(&refs->base, NULL, newrefname,
 			    NULL, REF_NO_DEREF)) {
 		if (errno == EISDIR) {
--
2.24.1

```

## Derrick Stolee, 2019-12-11 19:01

Subject: Re: [PATCH] refs: pass NULL to refs_read_ref_full() because object ID is not needed
Message-ID: <3f39d0f8-adfb-5f25-a724-f37f26904fa6@gmail.com>
URL: https://gitlist.dev/e/3f39d0f8-adfb-5f25-a724-f37f26904fa6%40gmail.com
In-Reply-To: <a762958e-324b-f9a5-96e4-fab0b4b91df8@web.de>

```
On 12/11/2019 1:46 PM, René Scharfe wrote:
> refs_read_ref_full() wraps refs_resolve_ref_unsafe(), which handles a
> NULL oid pointer of callers not interested in the resolved object ID.
> Pass NULL from files_copy_or_rename_ref() to clarify that it is one
> such caller.

I suppose this could have been grouped/threaded with the other
similar patch, but still correct. Thanks!

-Stolee

```
