git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eli Collins <eli@cloudera.com>
To: git@vger.kernel.org
Cc: Eli Collins <eli@cloudera.com>
Subject: [PATCH] diff: add configuration option for disabling diff prefixes.
Date: Sun,  2 May 2010 19:03:41 -0700	[thread overview]
Message-ID: <1272852221-14927-1-git-send-email-eli@cloudera.com> (raw)

From: Eli Collins <eli@cloudera.com>

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>
---
 Documentation/config.txt |    2 ++
 diff.c                   |    9 ++++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 92f851e..e883952 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -796,6 +796,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 d0ecbc3..07269c2 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,
@@ -100,6 +101,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"))
@@ -2559,7 +2564,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/";
 	}
-- 
1.7.1.dirty

             reply	other threads:[~2010-05-03  2:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-03  2:03 Eli Collins [this message]
2010-05-03  6:27 ` [PATCH] diff: add a 'path' meta header for non-renames and non-copies Bert Wesarg
2010-05-03  7:30   ` Junio C Hamano
2010-05-03  7:37     ` Bert Wesarg
2010-05-03 16:29       ` Junio C Hamano
2010-05-03 22:55         ` Bert Wesarg
2010-05-04  1:34           ` Junio C Hamano
2010-05-04 19:30             ` Bert Wesarg
2010-05-05 21:14               ` Eli Collins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1272852221-14927-1-git-send-email-eli@cloudera.com \
    --to=eli@cloudera.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).