diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-03-25 12:54:27 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-03-25 12:54:27 -0700 |
commit | ea1fd481b4e689f143142662a82fb62c9b2efb65 (patch) | |
tree | a9e2475bf714d67eafee037aa710023495cad21e /submodule.c | |
parent | d78374e578a1837ee73c45f944c420c6f3f64deb (diff) | |
parent | c29b3962af3df80a43fab4ead4875bd2ca275e4c (diff) | |
download | git-ea1fd481b4e689f143142662a82fb62c9b2efb65.tar.gz git-ea1fd481b4e689f143142662a82fb62c9b2efb65.tar.xz |
Merge branch 'jk/run-command-capture'
The run-command interface was easy to abuse and make a pipe for us
to read from the process, wait for the process to finish and then
attempt to read its output, which is a pattern that lead to a
deadlock. Fix such uses by introducing a helper to do this
correctly (i.e. we need to read first and then wait the process to
finish) and also add code to prevent such abuse in the run-command
helper.
* jk/run-command-capture:
run-command: forbid using run_command with piped output
trailer: use capture_command
submodule: use capture_command
wt-status: use capture_command
run-command: introduce capture_command helper
wt_status: fix signedness mismatch in strbuf_read call
wt-status: don't flush before running "submodule status"
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 d37d400b2..c0e6c81fc 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; |