From e7af8e49cd54f1784fa2a0e382f22ca2f98cf4d8 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 30 May 2011 10:19:05 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 't') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 045cee312c..92248d24c4 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 -- cgit v1.2.3