Instead of implementing line reading yet again, make use of our beautiful library functions. Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx> --- submodule.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/submodule.c b/submodule.c index 2c667ac95a..c1b7b78260 100644 --- a/submodule.c +++ b/submodule.c @@ -1041,11 +1041,9 @@ int fetch_populated_submodules(const struct argv_array *options, unsigned is_submodule_modified(const char *path, int ignore_untracked) { - ssize_t len; struct child_process cp = CHILD_PROCESS_INIT; struct strbuf buf = STRBUF_INIT; unsigned dirty_submodule = 0; - const char *line, *next_line; const char *git_dir; strbuf_addf(&buf, "%s/.git", path); @@ -1072,10 +1070,8 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked) if (start_command(&cp)) die("Could not run 'git status --porcelain' in submodule %s", path); - len = strbuf_read(&buf, cp.out, 1024); - line = buf.buf; - while (len > 2) { - if ((line[0] == '?') && (line[1] == '?')) { + while (strbuf_getwholeline_fd(&buf, cp.out, '\n') != EOF) { + if ((buf.buf[0] == '?') && (buf.buf[1] == '?')) { dirty_submodule |= DIRTY_SUBMODULE_UNTRACKED; if (dirty_submodule & DIRTY_SUBMODULE_MODIFIED) break; @@ -1085,12 +1081,6 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked) (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)) break; } - next_line = strchr(line, '\n'); - if (!next_line) - break; - next_line++; - len -= (next_line - line); - line = next_line; } close(cp.out); -- 2.12.1.438.gb674c4c09c