Skip to content

Commit 1d4974c

Browse files
peffgitster
authored andcommitted
submodule: use capture_command
In is_submodule_commit_present, we call run_command followed by a pipe read, which is prone to deadlock. It is unlikely to happen in this case, as rev-list should never produce more than a single line of output, but it does not hurt to avoid an anti-pattern (and using the helper simplifies the setup and cleanup). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5c950e9 commit 1d4974c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

submodule.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,10 @@ static int is_submodule_commit_present(const char *path, unsigned char sha1[20])
576576
cp.env = local_repo_env;
577577
cp.git_cmd = 1;
578578
cp.no_stdin = 1;
579-
cp.out = -1;
580579
cp.dir = path;
581-
if (!run_command(&cp) && !strbuf_read(&buf, cp.out, 1024))
580+
if (!capture_command(&cp, &buf, 1024) && !buf.len)
582581
is_present = 1;
583582

584-
close(cp.out);
585583
strbuf_release(&buf);
586584
}
587585
return is_present;

0 commit comments

Comments
 (0)