Skip to contentSkip to conversation

git: remove redundant notes_ref check

PATCH New Rose via GitGitGadget 1 participant 1 message Dec 18, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git: remove redundant notes_ref check

From: Seija Kijin <[email protected]>

Earlier in the init_notes function, notes_ref is guaranteed to be the default ref if it is NULL by then, making future checks for notes_ref to be redundant, and xstrdup_or_null can just be xstrdup.

---
git: remove redundant notes_ref check

Earlier in the init_notes function, notes_ref is guaranteed to be the default ref if it is NULL by then, making future checks for notes_ref to be redundant, and xstrdup_or_null can just be xstrdup.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1400%2FAtariDreams%2Fxstrdup-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1400/AtariDreams/xstrdup-v1
Pull-Request: https://github.com/git/git/pull/1400

 notes.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
notes.c +2 -3
index f2805d51bb1..a2283b9ace4 100644
@@ -1014,14 +1014,13 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
 	t->root = (struct int_node *) xcalloc(1, sizeof(struct int_node));
 	t->first_non_note = NULL;
 	t->prev_non_note = NULL;
-	t->ref = xstrdup_or_null(notes_ref);
+	t->ref = xstrdup(notes_ref);
 	t->update_ref = (flags & NOTES_INIT_WRITABLE) ? t->ref : NULL;
 	t->combine_notes = combine_notes;
 	t->initialized = 1;
 	t->dirty = 0;
 
-	if (flags & NOTES_INIT_EMPTY || !notes_ref ||
-	    get_oid_treeish(notes_ref, &object_oid))
+	if (flags & NOTES_INIT_EMPTY || get_oid_treeish(notes_ref, &object_oid))
 		return;
 	if (flags & NOTES_INIT_WRITABLE && read_ref(notes_ref, &object_oid))
 		die("Cannot use notes ref %s", notes_ref);

base-commit: 57e2c6ebbe7108b35ba30184dcbcb6c34c929ad8

Signature · 1 line
gitgitgadget