diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2024-03-15 02:03:10 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-15 18:04:45 +0100 |
commit | 7fdc2656331f051a673a61444051cde58044ceeb (patch) | |
tree | c9435a5630c8fcdf408a64e4c465ace41c8d4790 /diff.c | |
parent | The seventh batch (diff) | |
download | git-7fdc2656331f051a673a61444051cde58044ceeb.tar.xz git-7fdc2656331f051a673a61444051cde58044ceeb.zip |
diff: add diff.srcPrefix and diff.dstPrefix configuration variables
Allow the default prefixes "a/" and "b/" to be tweaked by the
diff.srcPrefix and diff.dstPrefix configuration variables.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -62,6 +62,8 @@ static const char *diff_order_file_cfg; int diff_auto_refresh_index = 1; static int diff_mnemonic_prefix; static int diff_no_prefix; +static const char *diff_src_prefix = "a/"; +static const char *diff_dst_prefix = "b/"; static int diff_relative; static int diff_stat_name_width; static int diff_stat_graph_width; @@ -408,6 +410,12 @@ int git_diff_ui_config(const char *var, const char *value, diff_no_prefix = git_config_bool(var, value); return 0; } + if (!strcmp(var, "diff.srcprefix")) { + return git_config_string(&diff_src_prefix, var, value); + } + if (!strcmp(var, "diff.dstprefix")) { + return git_config_string(&diff_dst_prefix, var, value); + } if (!strcmp(var, "diff.relative")) { diff_relative = git_config_bool(var, value); return 0; @@ -3425,8 +3433,8 @@ void diff_set_noprefix(struct diff_options *options) void diff_set_default_prefix(struct diff_options *options) { - options->a_prefix = "a/"; - options->b_prefix = "b/"; + options->a_prefix = diff_src_prefix; + options->b_prefix = diff_dst_prefix; } struct userdiff_driver *get_textconv(struct repository *r, @@ -5362,6 +5370,8 @@ static int diff_opt_default_prefix(const struct option *opt, BUG_ON_OPT_NEG(unset); BUG_ON_OPT_ARG(optarg); + diff_src_prefix = "a/"; + diff_dst_prefix = "b/"; diff_set_default_prefix(options); return 0; } |