Skip to content

Commit

Permalink
submodule: use capture_command
Browse files Browse the repository at this point in the history
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Mar 23, 2015
1 parent 5c950e9 commit 1d4974c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,10 @@ static int is_submodule_commit_present(const char *path, unsigned char sha1[20])
cp.env = local_repo_env;
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.out = -1;
cp.dir = path;
if (!run_command(&cp) && !strbuf_read(&buf, cp.out, 1024))
if (!capture_command(&cp, &buf, 1024) && !buf.len)
is_present = 1;

close(cp.out);
strbuf_release(&buf);
}
return is_present;
Expand Down

0 comments on commit 1d4974c

Please sign in to comment.