summaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-11-12 08:25:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-11-12 21:54:31 (GMT)
commit0b38227f283e208866d3e2ac85bcd947a71f1b17 (patch)
tree0603308f6f02634f6ee8a92ff98fb7ae15012a00 /builtin-commit.c
parent9db56f71b91153f4076a796c80c61f00edd8b700 (diff)
downloadgit-0b38227f283e208866d3e2ac85bcd947a71f1b17.zip
git-0b38227f283e208866d3e2ac85bcd947a71f1b17.tar.gz
git-0b38227f283e208866d3e2ac85bcd947a71f1b17.tar.bz2
commit: Fix stripping of patch in verbose mode.
When the "-v" option is given, we put diff of what is to be committed into the commit template, and then strip it back out again after the user has edited it. We used to look for the diff by searching for the "diff --git a/" header. With diff.mnemonicprefix set in the configuration, however, this pattern does not match. The pattern is loosened to cover this case. Also, if the user puts their own diff in the message (e.g., as a sample output), then we will accidentally trigger the pattern, removing part of their output. We can avoid doing this stripping altogether if the user didn't use "-v" in the first place, so we know that any match we find will be a false positive. [jc: this fix was split out of a series originally meant for master.] Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-commit.c')
-rw-r--r--builtin-commit.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index b563a0d..1e08399 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -1004,9 +1004,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
}
/* Truncate the message just before the diff, if any. */
- p = strstr(sb.buf, "\ndiff --git a/");
- if (p != NULL)
- strbuf_setlen(&sb, p - sb.buf + 1);
+ if (verbose) {
+ p = strstr(sb.buf, "\ndiff --git ");
+ if (p != NULL)
+ strbuf_setlen(&sb, p - sb.buf + 1);
+ }
if (cleanup_mode != CLEANUP_NONE)
stripspace(&sb, cleanup_mode == CLEANUP_ALL);