summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4c007ae)
raw | patch | inline | side by side (parent: 4c007ae)
author | Boris Faure <billiob@gmail.com> | |
Sun, 8 May 2011 10:31:02 +0000 (12:31 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 11 May 2011 18:20:28 +0000 (11:20 -0700) |
Templates should be just that: A form that the user fills out, and forms
have blanks. If people are attached to not having extra whitespace in the
editor, they can simply clean up their templates.
Added test with editor adding even more whitespace.
Signed-off-by: Boris Faure <billiob@gmail.com>
Based-on-patch-by:Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
have blanks. If people are attached to not having extra whitespace in the
editor, they can simply clean up their templates.
Added test with editor adding even more whitespace.
Signed-off-by: Boris Faure <billiob@gmail.com>
Based-on-patch-by:Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c | patch | blob | history | |
t/t7500-commit.sh | patch | blob | history | |
t/t7500/add-whitespaced-content | [new file with mode: 0755] | patch | blob |
diff --git a/builtin/commit.c b/builtin/commit.c
index 67757e999fba514b62767d3351031e9eb6ef8c10..411d5e41531adabe679df2d1381dbf923c5e925b 100644 (file)
--- a/builtin/commit.c
+++ b/builtin/commit.c
const char *hook_arg1 = NULL;
const char *hook_arg2 = NULL;
int ident_shown = 0;
+ int clean_message_contents = (cleanup_mode != CLEANUP_NONE);
if (!no_verify && run_hook(index_file, "pre-commit", NULL))
return 0;
if (strbuf_read_file(&sb, template_file, 0) < 0)
die_errno(_("could not read '%s'"), template_file);
hook_arg1 = "template";
+ clean_message_contents = 0;
}
/*
if (s->fp == NULL)
die_errno(_("could not open '%s'"), git_path(commit_editmsg));
- if (cleanup_mode != CLEANUP_NONE)
+ if (clean_message_contents)
stripspace(&sb, 0);
if (signoff) {
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index bcdf0847d0970f544e96afa0036ec12800422fd8..9ef00906cc5eb029c0236331e9a39f3d5272ab67 100755 (executable)
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
commit_msg_is "standard input msg"
'
+cat >"$TEMPLATE" <<\EOF
+
+
+### template
+
+EOF
+test_expect_success 'commit message from template with whitespace issue' '
+ echo "content galore" >>foo &&
+ git add foo &&
+ GIT_EDITOR="$TEST_DIRECTORY"/t7500/add-whitespaced-content git commit \
+ --template "$TEMPLATE" &&
+ commit_msg_is "commit message"
+'
+
test_expect_success 'using alternate GIT_INDEX_FILE (1)' '
cp .git/index saved-index &&
diff --git a/t/t7500/add-whitespaced-content b/t/t7500/add-whitespaced-content
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+sed -e 's/|$//' >>"$1" <<\EOF
+
+ |
+commit message |
+
+EOF
+exit 0