summaryrefslogtreecommitdiff
path: root/log-tree.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-05-30 14:19:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-30 18:18:59 (GMT)
commite7af8e49cd54f1784fa2a0e382f22ca2f98cf4d8 (patch)
treef2d0e8c81aefc447e6f8853fd660ca6e9e069d5f /log-tree.c
parentfb674d767180354d9ad3e69f1d41bee98df6bfe9 (diff)
downloadgit-e7af8e49cd54f1784fa2a0e382f22ca2f98cf4d8.zip
git-e7af8e49cd54f1784fa2a0e382f22ca2f98cf4d8.tar.gz
git-e7af8e49cd54f1784fa2a0e382f22ca2f98cf4d8.tar.bz2
format-patch: make zero-length subject prefixes prettier
If you give a zero-length subject prefix to format-patch (e.g., "format-patch --subject-prefix="), we will print the ugly: Subject: [ 1/2] your subject here because we always insert a space between the prefix and numbering. Requiring the user to provide the space in their prefix would be more flexible, but would break existing usage. This patch provides a DWIM and suppresses the space for zero-length prefixes, under the assumption that nobody actually wants "[ 1/2]". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c3
1 files changed, 2 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;