File tree 1 file changed +12
-0
lines changed
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,10 @@ func getCommitsInfo(state *getCommitsInfoState) error {
207
207
if err := cmd .Start (); err != nil {
208
208
return err
209
209
}
210
+ // it's okay to ignore the error returned by cmd.Wait(); we expect the
211
+ // subprocess to sometimes have a non-zero exit status, since we may
212
+ // prematurely close stdout, resulting in a broken pipe.
213
+ defer cmd .Wait ()
210
214
211
215
numThreads := runtime .NumCPU ()
212
216
done := make (chan error , numThreads )
@@ -216,6 +220,14 @@ func getCommitsInfo(state *getCommitsInfoState) error {
216
220
217
221
scanner := bufio .NewScanner (readCloser )
218
222
err = state .processGitLogOutput (scanner )
223
+
224
+ // it is important that we close stdout here; if we do not close
225
+ // stdout, the subprocess will keep running, and the deffered call
226
+ // cmd.Wait() may block for a long time.
227
+ if closeErr := readCloser .Close (); closeErr != nil && err == nil {
228
+ err = closeErr
229
+ }
230
+
219
231
for i := 0 ; i < numThreads ; i ++ {
220
232
doneErr := <- done
221
233
if doneErr != nil && err == nil {
You can’t perform that action at this time.
0 commit comments