Skip to content

Commit

Permalink
Merge branch 'jk/format-patch-empty-prefix'
Browse files Browse the repository at this point in the history
* jk/format-patch-empty-prefix:
  format-patch: make zero-length subject prefixes prettier
  • Loading branch information
Junio C Hamano committed May 31, 2011
2 parents 15af707 + e7af8e4 commit aca820a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion log-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions t/t4014-format-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit aca820a

Please sign in to comment.