diff options
author | Jiang Xin <zhiyou.jx@alibaba-inc.com> | 2020-04-17 11:45:32 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-04-17 21:16:31 +0200 |
commit | 7dcbeaa0df01661f31a0d93e5d5787a5d3767358 (patch) | |
tree | 09801410b978d6e1295793b7248514175c960e35 /t/t5504-fetch-receive-strict.sh | |
parent | Git 2.26 (diff) | |
download | git-7dcbeaa0df01661f31a0d93e5d5787a5d3767358.tar.xz git-7dcbeaa0df01661f31a0d93e5d5787a5d3767358.zip |
send-pack: fix inconsistent porcelain output
The porcelain output of a failed `git-push` command is inconsistent for
different protocols. For example, the following `git-push` command
may fail due to the failure of the `pre-receive` hook.
git push --porcelain origin HEAD:refs/heads/master
For SSH protocol, the porcelain output does not end with a "Done"
message:
To <URL/of/upstream.git>
! HEAD:refs/heads/master [remote rejected] (pre-receive hook declined)
While for HTTP protocol, the porcelain output does end with a "Done"
message:
To <URL/of/upstream.git>
! HEAD:refs/heads/master [remote rejected] (pre-receive hook declined)
Done
The following code at the end of function `send_pack()` indicates that
`send_pack()` should not return an error if some references are rejected
in porcelain mode.
int send_pack(...)
... ...
if (args->porcelain)
return 0;
for (ref = remote_refs; ref; ref = ref->next) {
switch (ref->status) {
case REF_STATUS_NONE:
case REF_STATUS_UPTODATE:
case REF_STATUS_OK:
break;
default:
return -1;
}
}
return 0;
}
So if atomic push failed, must check the porcelain mode before return
an error. And `receive_status()` should not return an error for a
failed updated reference, because `send_pack()` will check them instead.
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5504-fetch-receive-strict.sh')
-rwxr-xr-x | t/t5504-fetch-receive-strict.sh | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index 645b4c78d3..a32efe2b6c 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -65,6 +65,7 @@ test_expect_success 'fetch with transfer.fsckobjects' ' cat >exp <<EOF To dst ! refs/heads/master:refs/heads/test [remote rejected] (missing necessary objects) +Done EOF test_expect_success 'push without strict' ' |