diff options
author | Jeff King <peff@peff.net> | 2015-03-22 23:53:56 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-03-22 21:39:16 -0700 |
commit | 1d4974c9bcbe3c9c0611cb056730d49c6b0b6b5e (patch) | |
tree | 3d710c85d3e6be3db6663d4628bbb50df66266f5 /submodule.c | |
parent | 5c950e9bf098b17bb37e06f7c9f50d24e9d2904f (diff) | |
download | git-1d4974c9bcbe3c9c0611cb056730d49c6b0b6b5e.tar.gz |
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'submodule.c')
-rw-r--r-- | submodule.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/submodule.c b/submodule.c index d37d400b22..c0e6c81fc4 100644 --- a/submodule.c +++ b/submodule.c @@ -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; |