* [PATCH] git: remove redundant notes_ref check
@ 2022-12-18 21:41 Rose via GitGitGadget
0 siblings, 0 replies; only message in thread
From: Rose via GitGitGadget @ 2022-12-18 21:41 UTC (permalink / raw)
To: git; +Cc: Rose, Seija Kijin
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-18 21:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-18 21:41 [PATCH] git: remove redundant notes_ref check Rose via GitGitGadget
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).