aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-06-18 11:16:55 -0700
committerJunio C Hamano <gitster@pobox.com>2010-06-18 11:16:55 -0700
commit2621ac50cc2c7bb236f7f4abf8bbbb7f30168ff6 (patch)
treeb062385dea4a4fbcb012b1a485cb3f008707a057
parent880bd9d08081752bb4e2891aa3c16c82808ecb2e (diff)
parentf89504ddb9392fa6b9407957bf26905fd1d59d0a (diff)
downloadgit-2621ac50cc2c7bb236f7f4abf8bbbb7f30168ff6.tar.gz
git-2621ac50cc2c7bb236f7f4abf8bbbb7f30168ff6.tar.xz
Merge branch 'ec/diff-noprefix-config'
* ec/diff-noprefix-config: diff: add configuration option for disabling diff prefixes.
-rw-r--r--Documentation/config.txt2
-rw-r--r--diff.c9
2 files changed, 10 insertions, 1 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 95cf73cd4..7afd0a333 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -792,6 +792,8 @@ diff.mnemonicprefix::
standard "a/" and "b/" depending on what is being compared. When
this configuration is in effect, reverse diff output also swaps
the order of the prefixes:
+diff.noprefix::
+ If set, 'git diff' does not show any source or destination prefix.
`git diff`;;
compares the (i)ndex and the (w)ork tree;
`git diff HEAD`;;
diff --git a/diff.c b/diff.c
index 4e077445c..c82b605a9 100644
--- a/diff.c
+++ b/diff.c
@@ -30,6 +30,7 @@ static const char *diff_word_regex_cfg;
static const char *external_diff_cmd_cfg;
int diff_auto_refresh_index = 1;
static int diff_mnemonic_prefix;
+static int diff_no_prefix;
static char diff_colors[][COLOR_MAXLEN] = {
GIT_COLOR_RESET,
@@ -101,6 +102,10 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
diff_mnemonic_prefix = git_config_bool(var, value);
return 0;
}
+ if (!strcmp(var, "diff.noprefix")) {
+ diff_no_prefix = git_config_bool(var, value);
+ return 0;
+ }
if (!strcmp(var, "diff.external"))
return git_config_string(&external_diff_cmd_cfg, var, value);
if (!strcmp(var, "diff.wordregex"))
@@ -2625,7 +2630,9 @@ void diff_setup(struct diff_options *options)
DIFF_OPT_SET(options, COLOR_DIFF);
options->detect_rename = diff_detect_rename_default;
- if (!diff_mnemonic_prefix) {
+ if (diff_no_prefix) {
+ options->a_prefix = options->b_prefix = "";
+ } else if (!diff_mnemonic_prefix) {
options->a_prefix = "a/";
options->b_prefix = "b/";
}