Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: Some Commit Messages Scare git-rev-list

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:23
Subsystem: the rest · Maintainer: Linus Torvalds


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;
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help