From: Bert Wesarg <bert.wesarg@googlemail.com>
To: Eli Collins <eli@cloudera.com>
Cc: Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, Bert Wesarg <bert.wesarg@googlemail.com>
Subject: [PATCH] diff: add a 'path' meta header for non-renames and non-copies
Date: Mon, 3 May 2010 08:27:52 +0200 [thread overview]
Message-ID: <1272868072-12120-1-git-send-email-bert.wesarg@googlemail.com> (raw)
In-Reply-To: <1272852221-14927-1-git-send-email-eli@cloudera.com>
Hi Eli,
I like to have a path without any prefix in the diff header, too, but also like
to see the diff mnemonic prefix (see diff.mnemonicprefix config). For some
diffs there is such path, which is in the extended header of the diff for
copies and renames. So I wrote the appended patch wich adds also an extended
header for non-copies and non-renames which shows the path without any prefix.
Regards,
Bert
--- 8< ---
From: Bert Wesarg <bert.wesarg@googlemail.com>
Subject: [PATCH] diff: add a 'path' meta header for non-renames and non-copies
This way you have always a path without any diff mnemonic prefix.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
Documentation/config.txt | 4 ++++
Documentation/diff-generate-patch.txt | 4 ++++
diff.c | 12 ++++++++++--
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 92f851e..652365e 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -807,6 +807,10 @@ diff.mnemonicprefix::
`git diff --no-index a b`;;
compares two non-git things (1) and (2).
+diff.path::
+ Always add a 'path <path>' extended header into the diff output,
+ for non-copies and non-renames.
+
diff.renameLimit::
The number of files to consider when performing the copy/rename
detection; equivalent to the 'git diff' option '-l'.
diff --git a/Documentation/diff-generate-patch.txt b/Documentation/diff-generate-patch.txt
index 8f9a241..67ba78f 100644
--- a/Documentation/diff-generate-patch.txt
+++ b/Documentation/diff-generate-patch.txt
@@ -30,6 +30,7 @@ the file that rename/copy produces, respectively.
new mode <mode>
deleted file mode <mode>
new file mode <mode>
+ path <path>
copy from <path>
copy to <path>
rename from <path>
@@ -38,6 +39,9 @@ the file that rename/copy produces, respectively.
dissimilarity index <number>
index <hash>..<hash> <mode>
+ The 'path' header will only show up, if the diff.path configure option
+ is set.
+
3. TAB, LF, double quote and backslash characters in pathnames
are represented as `\t`, `\n`, `\"` and `\\`, respectively.
If there is need for such substitution then the whole
diff --git a/diff.c b/diff.c
index d0ecbc3..fa33b9c 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_path;
static char diff_colors[][COLOR_MAXLEN] = {
GIT_COLOR_RESET,
@@ -104,6 +105,10 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
return git_config_string(&external_diff_cmd_cfg, var, value);
if (!strcmp(var, "diff.wordregex"))
return git_config_string(&diff_word_regex_cfg, var, value);
+ if (!strcmp(var, "diff.path")) {
+ diff_path = git_config_bool(var, value);
+ return 0;
+ }
return git_diff_basic_config(var, value, cb);
}
@@ -2351,8 +2356,11 @@ static void fill_metainfo(struct strbuf *msg,
}
/* fallthru */
default:
- /* nothing */
- ;
+ if (diff_path) {
+ strbuf_addstr(msg, "path ");
+ quote_c_style(name, msg, NULL, 0);
+ strbuf_addch(msg, '\n');
+ }
}
if (one && two && hashcmp(one->sha1, two->sha1)) {
int abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;
--
tg: (ddd02b7..) bw/always-print-a-path-meta-header (depends on: master)
next prev parent reply other threads:[~2010-05-03 6:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-03 2:03 [PATCH] diff: add configuration option for disabling diff prefixes Eli Collins
2010-05-03 6:27 ` Bert Wesarg [this message]
2010-05-03 7:30 ` [PATCH] diff: add a 'path' meta header for non-renames and non-copies 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=1272868072-12120-1-git-send-email-bert.wesarg@googlemail.com \
--to=bert.wesarg@googlemail.com \
--cc=eli@cloudera.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).