git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git: remove redundant notes_ref check

From
RGRose via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 18, 2022, 21:41 UTC
Message-ID
<pull.1400.git.git.1671399699603.gitgitgadget@gmail.com>
From: Seija Kijin <doremylover123@gmail.com>

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.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    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(-)
diff --git a/notes.c b/notes.c
index f2805d51bb1..a2283b9ace4 100644
--- a/notes.c
+++ b/notes.c
@@ -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
-- 
gitgitgadget
Message 1 of 1 in “git: remove redundant notes_ref check”
  1. git: remove redundant notes_ref checkRose via GitGitGadget, Dec 18, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.