@@ -292,21 +292,8 @@ func (ghx *GitHTTPXfer) serviceRPC(ctx Context, rpc string) {
292
292
cleanUpProcessGroup (cmd )
293
293
}()
294
294
295
- stdin , err := cmd .StdinPipe ()
296
- if err != nil {
297
- ghx .logger .Error ("failed to get pipe that will be connected to the command's standard input. " , err .Error ())
298
- RenderInternalServerError (res .Writer )
299
- return
300
- }
301
- defer stdin .Close ()
302
-
303
- stdout , err := cmd .StdoutPipe ()
304
- if err != nil {
305
- ghx .logger .Error ("failed to get pipe that will be connected to the command's standard output. " , err .Error ())
306
- RenderInternalServerError (res .Writer )
307
- return
308
- }
309
- defer stdout .Close ()
295
+ cmd .Stdin = body
296
+ cmd .Stdout = res .Writer
310
297
311
298
err = cmd .Start ()
312
299
if err != nil {
@@ -315,24 +302,6 @@ func (ghx *GitHTTPXfer) serviceRPC(ctx Context, rpc string) {
315
302
return
316
303
}
317
304
318
- go func () {
319
- if _ , err := io .Copy (stdin , body ); err != nil {
320
- ghx .logger .Error ("failed to write the request body to standard input. " , err .Error ())
321
- RenderInternalServerError (res .Writer )
322
- return
323
- }
324
- // "git-upload-pack" waits for the remaining input and it hangs,
325
- // so must close it after completing the copy request body to standard input.
326
- stdin .Close ()
327
- }()
328
-
329
- go func () {
330
- if _ , err := io .Copy (res .Writer , stdout ); err != nil {
331
- ghx .logger .Error ("failed to write the standard output to response. " , err .Error ())
332
- return
333
- }
334
- }()
335
-
336
305
if err = cmd .Wait (); err != nil {
337
306
ghx .logger .Error ("specified command fails to run or doesn't complete successfully. " , err .Error ())
338
307
}
0 commit comments