--- raw/commit-tree.c 2005-05-26 23:38:30.000000000 -0400 +++ argp2/commit-tree.c 2005-05-27 12:46:54.000000000 -0400 @@ -90,6 +90,18 @@ free(buf); } +static int whitespace(const char *msg) +{ + while (*msg) + switch (*msg) { + case ' ': case '\t': case '\n': case '\r': + msg++; break; + default: + return 0; + } + return 1; +} + /* * Having more than two parents is not strange at all, and this is * how multi-way merges are represented. @@ -112,7 +124,7 @@ char comment[1000]; struct passwd *pw; char *buffer; - unsigned int size; + unsigned int size, csize; if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0) usage(commit_tree_usage); @@ -174,8 +186,10 @@ add_buffer(&buffer, &size, "committer %s <%s> %s\n\n", commitgecos, commitemail, realdate); /* And add the comment */ + csize = size; while (fgets(comment, sizeof(comment), stdin) != NULL) - add_buffer(&buffer, &size, "%s", comment); + if (size > csize || ! whitespace(comment)) + add_buffer(&buffer, &size, "%s", comment); write_sha1_file(buffer, size, "commit", commit_sha1); printf("%s\n", sha1_to_hex(commit_sha1));