On Tue, Nov 11, 2008 at 11:29 AM, Jeff King [off-list ref] wrote:
quoted hunk ↗ jump to hunk
On Tue, Nov 11, 2008 at 08:56:34AM +0100, Santi Béjar wrote:
quoted
Almost! I have diff.mnemonicprefix=true, if I unset it everything works.
Ah, indeed. The obvious fix is just loosening our match a little bit:
diff --git a/builtin-commit.c b/builtin-commit.c
index 93ca496..a721990 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -1015,7 +1015,7 @@ 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/");
+ p = strstr(sb.buf, "\ndiff --git ");
if (p != NULL)
strbuf_setlen(&sb, p - sb.buf + 1);
It fixes it, thanks.
But I have to wonder if there is some more robust solution. It seems
like this can have false positives if you include diff output in your
commit message, and a potential false negative if you delete the newline
(e.g., delete everything up to "diff --git", making it the first line).
But I guess we haven't seen a lot of complaints, so maybe those
conditions aren't worth worrying about.
The false positive/negative were already possible, it was just a
little more narrow. So not worth worrying about.
Also, if you really want a diff in the commit message you can use the
--cleanup option.
A more robust solution could be to have a:
# Everything after this line will be removed from the commit message
But, again, not worth.
Santi
-Peff