bundle: Accept prerequisites without commit messages

While explicitly stating that the commit message in a prerequisite line is optional, we required all lines with 40 or more characters to contain a space after the object name, bailing out if a line consisted of an object name only. This was to allow bundling a history to a commit without an message, but the code forgot that it already called rtrim() to remove that whitespace. As a workaround, only check for SP when the line has more than 40 characters. Signed-off-by: Lukas Fleischer <git@cryptocrack.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lukas Fleischer committed Apr 7, 2013 at 13:53 UTC 5446e33f35d6b27b6b760a59a6ded33fbd555190
2 files changed +11 -1
bundle.c
+1 -1
@@ -57,7 +57,7 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
57 * followed by SP and subject line.
58 */
59 if (get_sha1_hex(buf.buf, sha1) ||
60 - (40 <= buf.len && !isspace(buf.buf[40])) ||
60 + (buf.len > 40 && !isspace(buf.buf[40])) ||
61 (!is_prereq && buf.len <= 40)) {
62 if (report_path)
63 error(_("unrecognized header: %s%s (%d)"),
t/t5704-bundle.sh
+10
@@ -58,4 +58,14 @@ test_expect_success 'ridiculously long subject in boundary' '
58 grep "^-[0-9a-f]\\{40\\} " boundary
59 '
60
61 +test_expect_success 'prerequisites with an empty commit message' '
62 + : >file1 &&
63 + git add file1 &&
64 + test_tick &&
65 + git commit --allow-empty-message -m "" &&
66 + test_commit file2 &&
67 + git bundle create bundle HEAD^.. &&
68 + git bundle verify bundle
69 +'
70 +
71 test_done