diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2017-12-21 23:00:30 -0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-12-22 09:00:30 +0200 |
commit | 156aa42ba00c52e56be5ceca1615a574fa1fd052 (patch) | |
tree | bc7c42079ccccc85ad267d4637e7d86283645062 /vendor/code.gitea.io | |
parent | 515cdaa85d6087d91a61ebe74fae39e0c4bdf1c4 (diff) | |
download | gitea-156aa42ba00c52e56be5ceca1615a574fa1fd052.tar.gz gitea-156aa42ba00c52e56be5ceca1615a574fa1fd052.zip |
Update code.gitea.io/git (#3251)
Diffstat (limited to 'vendor/code.gitea.io')
-rw-r--r-- | vendor/code.gitea.io/git/commit_info.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/vendor/code.gitea.io/git/commit_info.go b/vendor/code.gitea.io/git/commit_info.go index 106ebc618f..6b42b57c90 100644 --- a/vendor/code.gitea.io/git/commit_info.go +++ b/vendor/code.gitea.io/git/commit_info.go @@ -207,6 +207,10 @@ func getCommitsInfo(state *getCommitsInfoState) error { if err := cmd.Start(); err != nil { return err } + // it's okay to ignore the error returned by cmd.Wait(); we expect the + // subprocess to sometimes have a non-zero exit status, since we may + // prematurely close stdout, resulting in a broken pipe. + defer cmd.Wait() numThreads := runtime.NumCPU() done := make(chan error, numThreads) @@ -216,6 +220,14 @@ func getCommitsInfo(state *getCommitsInfoState) error { scanner := bufio.NewScanner(readCloser) err = state.processGitLogOutput(scanner) + + // it is important that we close stdout here; if we do not close + // stdout, the subprocess will keep running, and the deffered call + // cmd.Wait() may block for a long time. + if closeErr := readCloser.Close(); closeErr != nil && err == nil { + err = closeErr + } + for i := 0; i < numThreads; i++ { doneErr := <-done if doneErr != nil && err == nil { |