Skip to content

Commit 735907b

Browse files
committed
Merge branch 'jk/http-push-status-fix'
"git push" client talking to an HTTP server did not diagnose the lack of the final status report from the other side correctly, which has been corrected. * jk/http-push-status-fix: transport-helper: recognize "expecting report" error from send-pack send-pack: complain about "expecting report" with --helper-status
2 parents 8ba651b + c5c3486 commit 735907b

File tree

6 files changed

+35
-0
lines changed

6 files changed

+35
-0
lines changed

builtin/send-pack.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ static void print_helper_status(struct ref *ref)
8787
break;
8888

8989
case REF_STATUS_EXPECTING_REPORT:
90+
res = "error";
91+
msg = "expecting report";
92+
break;
93+
9094
default:
9195
continue;
9296
}

t/lib-httpd.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ prepare_httpd() {
131131
cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
132132
install_script incomplete-length-upload-pack-v2-http.sh
133133
install_script incomplete-body-upload-pack-v2-http.sh
134+
install_script error-no-report.sh
134135
install_script broken-smart-http.sh
135136
install_script error-smart-http.sh
136137
install_script error.sh

t/lib-httpd/apache.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Alias /auth/dumb/ www/auth/dumb/
122122
</LocationMatch>
123123
ScriptAlias /smart/incomplete_length/git-upload-pack incomplete-length-upload-pack-v2-http.sh/
124124
ScriptAlias /smart/incomplete_body/git-upload-pack incomplete-body-upload-pack-v2-http.sh/
125+
ScriptAlias /smart/no_report/git-receive-pack error-no-report.sh/
125126
ScriptAliasMatch /error_git_upload_pack/(.*)/git-upload-pack error.sh/
126127
ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
127128
ScriptAlias /broken_smart/ broken-smart-http.sh/
@@ -137,6 +138,9 @@ ScriptAliasMatch /one_time_perl/(.*) apply-one-time-perl.sh/$1
137138
<Files incomplete-body-upload-pack-v2-http.sh>
138139
Options ExecCGI
139140
</Files>
141+
<Files error-no-report.sh>
142+
Options ExecCGI
143+
</Files>
140144
<Files broken-smart-http.sh>
141145
Options ExecCGI
142146
</Files>

t/lib-httpd/error-no-report.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
echo "Content-Type: application/x-git-receive-pack-result"
2+
echo
3+
printf '0013\001000eunpack ok\n'
4+
printf '0015\002skipping report\n'
5+
printf '0009\0010000'
6+
printf '0000'

t/t5541-http-push-smart.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,20 @@ test_expect_success 'colorize errors/hints' '
509509
test_i18ngrep ! "^hint: " decoded
510510
'
511511

512+
test_expect_success 'report error server does not provide ref status' '
513+
git init "$HTTPD_DOCUMENT_ROOT_PATH/no_report" &&
514+
git -C "$HTTPD_DOCUMENT_ROOT_PATH/no_report" config http.receivepack true &&
515+
test_must_fail git push --porcelain \
516+
$HTTPD_URL_USER_PASS/smart/no_report \
517+
HEAD:refs/tags/will-fail >actual &&
518+
test_must_fail git -C "$HTTPD_DOCUMENT_ROOT_PATH/no_report" \
519+
rev-parse --verify refs/tags/will-fail &&
520+
cat >expect <<-EOF &&
521+
To $HTTPD_URL/smart/no_report
522+
! HEAD:refs/tags/will-fail [remote failure] (remote failed to report status)
523+
Done
524+
EOF
525+
test_cmp expect actual
526+
'
527+
512528
test_done

transport-helper.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,10 @@ static int push_update_ref_status(struct strbuf *buf,
845845
forced = 1;
846846
FREE_AND_NULL(msg);
847847
}
848+
else if (!strcmp(msg, "expecting report")) {
849+
status = REF_STATUS_EXPECTING_REPORT;
850+
FREE_AND_NULL(msg);
851+
}
848852
}
849853

850854
if (state->hint)

0 commit comments

Comments
 (0)