summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-31 19:09:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-31 19:09:27 (GMT)
commitaca820ae61bc376315b6bb1aea2e0006d1d273b6 (patch)
tree744e47d6e5091fa5874d612bbaf92a11b4713f9b
parent15af7075fc21877320a3fcf251201b209af5253a (diff)
parente7af8e49cd54f1784fa2a0e382f22ca2f98cf4d8 (diff)
downloadgit-aca820ae61bc376315b6bb1aea2e0006d1d273b6.zip
git-aca820ae61bc376315b6bb1aea2e0006d1d273b6.tar.gz
git-aca820ae61bc376315b6bb1aea2e0006d1d273b6.tar.bz2
Merge branch 'jk/format-patch-empty-prefix'
* jk/format-patch-empty-prefix: format-patch: make zero-length subject prefixes prettier
-rw-r--r--log-tree.c3
-rwxr-xr-xt/t4014-format-patch.sh18
2 files changed, 20 insertions, 1 deletions
diff --git a/log-tree.c b/log-tree.c
index 2a1e3a9..296f417 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -294,8 +294,9 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
if (opt->total > 0) {
static char buffer[64];
snprintf(buffer, sizeof(buffer),
- "Subject: [%s %0*d/%d] ",
+ "Subject: [%s%s%0*d/%d] ",
opt->subject_prefix,
+ *opt->subject_prefix ? " " : "",
digits_in_number(opt->total),
opt->nr, opt->total);
subject = buffer;
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 045cee3..92248d2 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -851,4 +851,22 @@ test_expect_success 'subject lines do not have 822 atom-quoting' '
test_cmp expect actual
'
+cat >expect <<'EOF'
+Subject: [PREFIX 1/1] header with . in it
+EOF
+test_expect_success 'subject prefixes have space prepended' '
+ git format-patch -n -1 --stdout --subject-prefix=PREFIX >patch &&
+ grep ^Subject: patch >actual &&
+ test_cmp expect actual
+'
+
+cat >expect <<'EOF'
+Subject: [1/1] header with . in it
+EOF
+test_expect_success 'empty subject prefix does not have extra space' '
+ git format-patch -n -1 --stdout --subject-prefix= >patch &&
+ grep ^Subject: patch >actual &&
+ test_cmp expect actual
+'
+
test_done