@matheusbsbs / matheus-bagliano / commits / 85cf643f1b
Fork 0

for-each-ref: Fix --format=%(subject) for log message without newlines

'git for-each-ref --format=%(subject)' currently returns an empty string if the log message does not contain a newline. This patch teaches 'git for-each-ref' to return the entire log message (instead of an empty string) if there is no newline in the log message. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Johan Herland committed Sep 25, 2008 at 01:10 UTC 85cf643f1b17ee5680ae816eb061f569b4e00478
1 file changed +2 -2
builtin-for-each-ref.c
+2 -2
@@ -321,8 +321,8 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
321 static const char *copy_line(const char *buf)
322 {
323 const char *eol = strchr(buf, '\n');
324 - if (!eol)
325 - return "";
324 + if (!eol) // simulate strchrnul()
325 + eol = buf + strlen(buf);
326 return xmemdupz(buf, eol - buf);
327 }
328