From de984e24590178ea777415b286a91bf1f5998cd8 Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Thu, 23 May 2024 19:06:18 +0200 Subject: [PATCH] Fix parsing of `--no-prefix` argument --- NEWS.adoc | 4 ++++ src/options.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index a046db1ac..d6a78f070 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -4,6 +4,10 @@ Release notes master ------ +Bug fixes: + + - Fix parsing of `--no-prefix` argument. + Improvements: - Open the blob corresponding to the diff line. (#1334) diff --git a/src/options.c b/src/options.c index 0bd0c0f7f..019318738 100644 --- a/src/options.c +++ b/src/options.c @@ -278,6 +278,12 @@ update_options_from_argv(const char *argv[]) /* Keep the flag in argv. */ } + if (!strcmp(flag, "--no-prefix")) { + opt_diff_noprefix = true; + mark_option_seen(&opt_diff_noprefix); + /* Keep the flag in argv. */ + } + argv[flags_pos++] = flag; } @@ -1531,10 +1537,11 @@ read_repo_config_option(char *name, size_t namelen, char *value, size_t valuelen else if (!strcmp(name, "core.abbrev")) parse_int(&opt_id_width, value, 0, SIZEOF_REV - 1); - else if (!strcmp(name, "diff.noprefix")) - parse_bool(&opt_diff_noprefix, value); + else if (!strcmp(name, "diff.noprefix")) { + if (!find_option_info_by_value(&opt_diff_noprefix)->seen) + parse_bool(&opt_diff_noprefix, value); - else if (!strcmp(name, "status.showuntrackedfiles")) + } else if (!strcmp(name, "status.showuntrackedfiles")) opt_status_show_untracked_files = !!strcmp(value, "no"), opt_status_show_untracked_dirs = !strcmp(value, "all");