From: Jeff King Date: Sun, 22 Mar 2015 10:08:59 GMT Subject: [PATCH 5/7] submodule: use strbuf_read_cmd Message-ID: <20150322100858.GE11615@peff.net> In-Reply-To: <20150322095924.GA24651@peff.net> 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 --- submodule.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/submodule.c b/submodule.c index d37d400..d85f1bb 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 (!strbuf_read_cmd(&buf, &cp, 1024) && !buf.len) is_present = 1; - close(cp.out); strbuf_release(&buf); } return is_present; -- 2.3.3.618.ga041503