diff options
author | Denton Liu <liu.denton@gmail.com> | 2019-12-09 16:10:46 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-12-10 00:37:20 +0300 |
commit | 8164c961e16834da283cbf5ac5d22313b982a484 (patch) | |
tree | fb4dc18bb93b80061d0879985538d87a82f298f5 /builtin/log.c | |
parent | 452538c3586a76939faf43019fb7c21b3147309b (diff) |
format-patch: use --notes behavior for format.notes
When we had multiple `format.notes` config values where we had `<ref1>`,
`false`, `<ref2>` (in that order), then we would print out the notes for
both `<ref1>` and `<ref2>`. This doesn't make sense, however, since we
parse the config in a top-down manner and a `false` should be able to
override previous configurations, just like how `--no-notes` will
override previous `--notes`.
Duplicate the logic that handles the `--[no-]notes[=]` option to
`format.notes` for consistency. As a result, when parsing the config
from top to bottom, `format.notes = true` will behave like `--notes`,
`format.notes = <ref>` will behave like `--notes=<ref>` and
`format.notes = false` will behave like `--no-notes`.
This change isn't strictly backwards compatible but since it is an edge
case where a sane user would not mix notes refs with `false` and this
feature is relatively new (released only in v2.23.0), this change should
be harmless.
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/log.c')
-rw-r--r-- | builtin/log.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/builtin/log.c b/builtin/log.c index 622d6a6cb1..1f0405f72b 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -867,19 +867,8 @@ static int git_format_config(const char *var, const char *value, void *cb) return 0; } if (!strcmp(var, "format.notes")) { - struct strbuf buf = STRBUF_INIT; int b = git_parse_maybe_bool(value); - if (!b) - return 0; - rev->show_notes = 1; - if (b < 0) { - strbuf_addstr(&buf, value); - expand_notes_ref(&buf); - string_list_append(&rev->notes_opt.extra_notes_refs, - strbuf_detach(&buf, NULL)); - } else { - rev->notes_opt.use_default_notes = 1; - } + rev->show_notes = set_display_notes(&rev->notes_opt, b, b < 0 ? value : NULL); return 0; } |