diff options
author | Denton Liu <liu.denton@gmail.com> | 2019-12-09 05:10:44 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-12-09 13:36:45 -0800 |
commit | 452538c3586a76939faf43019fb7c21b3147309b (patch) | |
tree | 59871359eee629a5b38711cdb9feb6fc6a3b95f6 /revision.c | |
parent | e6e230eeae0f3cb46c4c356e6cd0a0f1119a2a83 (diff) | |
download | git-452538c3586a76939faf43019fb7c21b3147309b.tar.gz |
notes: extract logic into set_display_notes()
Instead of open coding the logic that tweaks the variables in
`struct display_notes_opt` within handle_revision_opt(), abstract away the
logic into set_display_notes() so that it can be reused.
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/revision.c b/revision.c index 24ad974590..c2d8d24939 100644 --- a/revision.c +++ b/revision.c @@ -2172,9 +2172,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg die("'%s': not a non-negative integer", arg); revs->expand_tabs_in_log = val; } else if (!strcmp(arg, "--show-notes") || !strcmp(arg, "--notes")) { - revs->show_notes = 1; + revs->show_notes = set_display_notes(&revs->notes_opt, 1, NULL); revs->show_notes_given = 1; - revs->notes_opt.use_default_notes = 1; } else if (!strcmp(arg, "--show-signature")) { revs->show_signature = 1; } else if (!strcmp(arg, "--no-show-signature")) { @@ -2189,25 +2188,14 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->track_first_time = 1; } else if (skip_prefix(arg, "--show-notes=", &optarg) || skip_prefix(arg, "--notes=", &optarg)) { - struct strbuf buf = STRBUF_INIT; - revs->show_notes = 1; - revs->show_notes_given = 1; if (starts_with(arg, "--show-notes=") && revs->notes_opt.use_default_notes < 0) revs->notes_opt.use_default_notes = 1; - strbuf_addstr(&buf, optarg); - expand_notes_ref(&buf); - string_list_append(&revs->notes_opt.extra_notes_refs, - strbuf_detach(&buf, NULL)); + revs->show_notes = set_display_notes(&revs->notes_opt, 1, optarg); + revs->show_notes_given = 1; } else if (!strcmp(arg, "--no-notes")) { - revs->show_notes = 0; + revs->show_notes = set_display_notes(&revs->notes_opt, 0, NULL); revs->show_notes_given = 1; - revs->notes_opt.use_default_notes = -1; - /* we have been strdup'ing ourselves, so trick - * string_list into free()ing strings */ - revs->notes_opt.extra_notes_refs.strdup_strings = 1; - string_list_clear(&revs->notes_opt.extra_notes_refs, 0); - revs->notes_opt.extra_notes_refs.strdup_strings = 0; } else if (!strcmp(arg, "--standard-notes")) { revs->show_notes_given = 1; revs->notes_opt.use_default_notes = 1; |