Merge branch 'sb/submodule-helper-clone-regression-fix' into maint
[gitweb.git] / builtin / check-attr.c
index 265c9ba02264d29eb3f63f1a8264c9fe7e642332..53a5a18c1681f5f13f6ddd4fd4d7d30c0ea14ce6 100644 (file)
@@ -72,23 +72,23 @@ static void check_attr(const char *prefix, int cnt,
 static void check_attr_stdin_paths(const char *prefix, int cnt,
        struct git_attr_check *check)
 {
-       struct strbuf buf, nbuf;
-       int line_termination = nul_term_line ? 0 : '\n';
-
-       strbuf_init(&buf, 0);
-       strbuf_init(&nbuf, 0);
-       while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
-               if (line_termination && buf.buf[0] == '"') {
-                       strbuf_reset(&nbuf);
-                       if (unquote_c_style(&nbuf, buf.buf, NULL))
+       struct strbuf buf = STRBUF_INIT;
+       struct strbuf unquoted = STRBUF_INIT;
+       strbuf_getline_fn getline_fn;
+
+       getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
+       while (getline_fn(&buf, stdin) != EOF) {
+               if (!nul_term_line && buf.buf[0] == '"') {
+                       strbuf_reset(&unquoted);
+                       if (unquote_c_style(&unquoted, buf.buf, NULL))
                                die("line is badly quoted");
-                       strbuf_swap(&buf, &nbuf);
+                       strbuf_swap(&buf, &unquoted);
                }
                check_attr(prefix, cnt, check, buf.buf);
                maybe_flush_or_die(stdout, "attribute to stdout");
        }
        strbuf_release(&buf);
-       strbuf_release(&nbuf);
+       strbuf_release(&unquoted);
 }
 
 static NORETURN void error_with_usage(const char *msg)