diff: add configuration option for disabling diff prefixes.
With new configuration "diff.noprefix", "git diff" does not show a source or destination prefix ala "git diff --no-prefix". Signed-off-by: Eli Collins <eli@cloudera.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eli Collins committed
May 2, 2010 at 19:03 UTC
f89504ddb9392fa6b9407957bf26905fd1d59d0a
2 files changed
+10
-1
Documentation/config.txt
+2
@@ -798,6 +798,8 @@ diff.mnemonicprefix::
798
standard "a/" and "b/" depending on what is being compared. When
799
this configuration is in effect, reverse diff output also swaps
800
the order of the prefixes:
801
+diff.noprefix::
802
+ If set, 'git diff' does not show any source or destination prefix.
803
`git diff`;;
804
compares the (i)ndex and the (w)ork tree;
805
`git diff HEAD`;;
diff.c
+8
-1
@@ -30,6 +30,7 @@ static const char *diff_word_regex_cfg;
30
static const char *external_diff_cmd_cfg;
31
int diff_auto_refresh_index = 1;
32
static int diff_mnemonic_prefix;
33
+static int diff_no_prefix;
34
35
static char diff_colors[][COLOR_MAXLEN] = {
36
GIT_COLOR_RESET,
@@ -101,6 +102,10 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
102
diff_mnemonic_prefix = git_config_bool(var, value);
103
return 0;
104
}
105
+ if (!strcmp(var, "diff.noprefix")) {
106
+ diff_no_prefix = git_config_bool(var, value);
107
+ return 0;
108
+ }
109
if (!strcmp(var, "diff.external"))
110
return git_config_string(&external_diff_cmd_cfg, var, value);
111
if (!strcmp(var, "diff.wordregex"))
@@ -2538,7 +2543,9 @@ void diff_setup(struct diff_options *options)
2543
DIFF_OPT_SET(options, COLOR_DIFF);
2544
options->detect_rename = diff_detect_rename_default;
2545
2541
- if (!diff_mnemonic_prefix) {
2546
+ if (diff_no_prefix) {
2547
+ options->a_prefix = options->b_prefix = "";
2548
+ } else if (!diff_mnemonic_prefix) {
2549
options->a_prefix = "a/";
2550
options->b_prefix = "b/";
2551
}