diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 21e92bbcb577c0361df51bd81e6fb5ab546619ea..72c087840c39bc03b142ba620f94800d40264eb9 100644 (file)
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -320,9 +320,7 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
static const char *copy_line(const char *buf)
{
- const char *eol = strchr(buf, '\n');
- if (!eol)
- return "";
+ const char *eol = strchrnul(buf, '\n');
return xmemdupz(buf, eol - buf);
}