{"thread":{"id":"58974","subject":"[PATCH] git: remove redundant notes_ref check","startedAt":"2022-12-18T21:41:49Z","lastAt":"2022-12-18T21:41:49Z","messageCount":1,"participants":["Rose via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"469254","messageId":"pull.1400.git.git.1671399699603.gitgitgadget@gmail.com","threadId":"58974","inReplyTo":null,"subject":"[PATCH] git: remove redundant notes_ref check","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-12-18T21:41:39Z","receivedAt":"2022-12-18T21:41:49Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nEarlier in the init_notes function, notes_ref is guaranteed\nto be the default ref if it is NULL by then,\nmaking future checks for notes_ref to be redundant,\nand xstrdup_or_null can just be xstrdup.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    git: remove redundant notes_ref check\n    \n    Earlier in the init_notes function, notes_ref is guaranteed to be the\n    default ref if it is NULL by then, making future checks for notes_ref to\n    be redundant, and xstrdup_or_null can just be xstrdup.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1400%2FAtariDreams%2Fxstrdup-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1400/AtariDreams/xstrdup-v1\nPull-Request: https://github.com/git/git/pull/1400\n\n notes.c | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/notes.c b/notes.c\nindex f2805d51bb1..a2283b9ace4 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -1014,14 +1014,13 @@ void init_notes(struct notes_tree *t, const char *notes_ref,\n \tt->root = (struct int_node *) xcalloc(1, sizeof(struct int_node));\n \tt->first_non_note = NULL;\n \tt->prev_non_note = NULL;\n-\tt->ref = xstrdup_or_null(notes_ref);\n+\tt->ref = xstrdup(notes_ref);\n \tt->update_ref = (flags & NOTES_INIT_WRITABLE) ? t->ref : NULL;\n \tt->combine_notes = combine_notes;\n \tt->initialized = 1;\n \tt->dirty = 0;\n \n-\tif (flags & NOTES_INIT_EMPTY || !notes_ref ||\n-\t    get_oid_treeish(notes_ref, &object_oid))\n+\tif (flags & NOTES_INIT_EMPTY || get_oid_treeish(notes_ref, &object_oid))\n \t\treturn;\n \tif (flags & NOTES_INIT_WRITABLE && read_ref(notes_ref, &object_oid))\n \t\tdie(\"Cannot use notes ref %s\", notes_ref);\n\nbase-commit: 57e2c6ebbe7108b35ba30184dcbcb6c34c929ad8\n-- \ngitgitgadget\n"}]}