[PATCH] git: remove redundant notes_ref check
- From
- Rose 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