git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Some Commit Messages Scare git-rev-list

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 12, 2006, 17:23 UTC
Message-ID
<Pine.LNX.4.64.0604121002220.14565@g5.osdl.org>
In-Reply-To
<1144847462.5213.6.camel@localhost.localdomain>
On Wed, 12 Apr 2006, Darrin Thompson wrote:
>
> This scripts exhibits some odd behavior. Apparently git-rev-list
> mishandles commit messages which do not end in a newline. This as best I
> can tell this is a problem introduced since 1.1.5.
Fixed like so..

However, your script shows another problem: the "#" added at the end of the line for a

	echo -n "duh" | git-commit -F - -a

seems to be because we append the "git status" output to it, and then we drop the lines that start with a '#', but due to the "-n", the first # ends up being at the end of the line.

I suspect that when we get the commit message like that, we should _not_ do any of the commit message editing at all.

That's a separate issue, though, and not fixed by this patch.
		Linus
---
diff --git a/commit.c b/commit.c
index d534c9b..c7bb8db 100644
--- a/commit.c
+++ b/commit.c
@@ -400,11 +400,11 @@ static int get_one_line(const char *msg,
 
 	while (len--) {
 		char c = *msg++;
+		if (!c)
+			break;
 		ret++;
 		if (c == '\n')
 			break;
-		if (!c)
-			return 0;
 	}
 	return ret;
 }
Previous: Darrin ThompsonNext: Junio C Hamano
Message 2 of 5 in “Some Commit Messages Scare git-rev-list”
  1. Darrin ThompsonApr 12, 2006
  2. Linus TorvaldsApr 12, 2006
  3. Junio C HamanoApr 12, 2006
  4. Junio C HamanoApr 12, 2006
  5. Linus TorvaldsApr 12, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.