From 7fc0458a7b54dacaee3ba17d9a9d4d60309176c0 Mon Sep 17 00:00:00 2001 From: "yuichi.watanabe" Date: Mon, 14 May 2018 21:28:55 +0900 Subject: [PATCH 1/2] close stdin after completing the copy body to stdin (#32) --- .gitignore | 1 + githttpxfer/githttpxfer.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 006b827..c81ef68 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Intellij idea .idea/* +*.iml # Binaries for programs and plugins *.exe diff --git a/githttpxfer/githttpxfer.go b/githttpxfer/githttpxfer.go index f05708f..d2d0a8e 100644 --- a/githttpxfer/githttpxfer.go +++ b/githttpxfer/githttpxfer.go @@ -280,6 +280,9 @@ func (ghx *GitHTTPXfer) serviceRPC(ctx Context, rpc string) { RenderInternalServerError(res.Writer) return } + // "git-upload-pack" waits for the remaining input and it hangs, + // so must close it after completing the copy request body to standard input. + stdin.Close() res.SetContentType(fmt.Sprintf("application/x-git-%s-result", rpc)) res.WriteHeader(http.StatusOK) From 05a72e003606cf05081eaef47b4ef2f92df11446 Mon Sep 17 00:00:00 2001 From: "yuichi.watanabe" Date: Mon, 14 May 2018 21:39:01 +0900 Subject: [PATCH 2/2] add test for git clone with depth option (#32) --- githttpxfer/githttpxfer_end_to_end_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/githttpxfer/githttpxfer_end_to_end_test.go b/githttpxfer/githttpxfer_end_to_end_test.go index ebfc281..ec7cd8b 100644 --- a/githttpxfer/githttpxfer_end_to_end_test.go +++ b/githttpxfer/githttpxfer_end_to_end_test.go @@ -95,8 +95,10 @@ func Test_End_To_End_it_should_succeed_clone_and_push_and_fetch_and_log(t *testi destDirNameA := "test_a" destDirNameB := "test_b" + destDirNameC := "test_c" destDirPathA := path.Join(endToEndTestParams.workingDirPath, destDirNameA) destDirPathB := path.Join(endToEndTestParams.workingDirPath, destDirNameB) + destDirPathC := path.Join(endToEndTestParams.workingDirPath, destDirNameC) if _, err := execCmd("", "git", "clone", remoteRepoUrl, destDirPathA); err != nil { t.Errorf("execute command error: %s", err.Error()) @@ -148,6 +150,11 @@ func Test_End_To_End_it_should_succeed_clone_and_push_and_fetch_and_log(t *testi return } + if _, err := execCmd("", "git", "clone", "--depth=1", remoteRepoUrl, destDirPathC); err != nil { + t.Errorf("execute command error: %s", err.Error()) + return + } + } func Test_End_To_End_it_should_succeed_request_to_get_info_refs(t *testing.T) {