summaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2007-11-21 21:54:49 -0500
committerJunio C Hamano <gitster@pobox.com>2007-11-22 17:05:05 -0800
commit99a12694582e2148fcd492f1eedaddcfe2a21621 (patch)
treec9d7b3648fd3428062fdb316c4ec4036aa250622 /builtin-commit.c
parent2888605c649ccd423232161186d72c0e6c458a48 (diff)
downloadgit-99a12694582e2148fcd492f1eedaddcfe2a21621.tar.gz
builtin-commit: Include the diff in the commit message when verbose.
run_diff_index() and the entire diff machinery is hard coded to output to stdout, so just redirect that and restore it when done. Signed-off-by: Kristian Høgsberg <krh@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-commit.c')
-rw-r--r--builtin-commit.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index e779db8ca3..4de316a366 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -662,7 +662,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
int header_len;
struct strbuf sb;
const char *index_file, *reflog_msg;
- char *nl;
+ char *nl, *p;
unsigned char commit_sha1[20];
struct ref_lock *ref_lock;
@@ -758,6 +758,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
rollback_index_files();
exit(1);
}
+
+ /* 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);
+
stripspace(&sb, 1);
if (sb.len < header_len || message_is_empty(&sb, header_len)) {
rollback_index_files();