for-each-ref: Fix --format=%(subject) for log message without newlines
Quoted 8 lines · Johan Herland
builtin-for-each-ref.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)builtin-for-each-ref.c +0
-0
builtin-for-each-ref.c static const char *find_wholine(const char *who, int wholen, const char *buf, un · line 327
Quoted 9 lines
builtin-for-each-ref.c +2
-2@@ -321,8 +321,8 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, unstatic const char *copy_line (const char *buf) {const char *eol =strchr (buf,'\n' ); -if (!eol) -return "" ; +if (!eol)// simulate strchrnul() + eol = buf +strlen (buf);return xmemdupz (buf, eol - buf); }
Why does this C++ style comment talk about "simulate"?
Don't other parts of git already use strchrnul()?
Signature · 2 lines
Nanako Shiraishi http://ivory.ap.teacup.com/nanako3/
PATCH 1/1 Use strchrnul() instead of strchr() plus manual workaround
Also gets rid of a C++ comment.
Signed-off-by Johan Herland <[email protected]>
---
Quoted 3 lines · Nanako Shiraishi
Why does this C++ style comment talk about "simulate"?
Don't other parts of git already use
strchrnul()?
Oops. Sorry about that. The man page for strchrnul() says that it is a GNU extension, so I stayed away from it. Of course, I should have grepped the git source instead...
This should fix it.
...Johan
builtin-for-each-ref.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
builtin-for-each-ref.c +1 -3
@@ -320,9 +320,7 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, unstatic const char *copy_line (const char *buf) { -const char *eol =strchr (buf,'\n' ); -if (!eol)// simulate strchrnul() - eol = buf +strlen (buf); +const char *eol =strchrnul (buf,'\n' );return xmemdupz (buf, eol - buf); }
Signature · 1 line
1.6.0.2.471.g47a76