diff options
author | Jiang Xin <zhiyou.jx@alibaba-inc.com> | 2020-04-17 05:45:36 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-04-17 12:16:32 -0700 |
commit | dfe1b7f19c04fd10e9bafce91bc1da0c18bbb194 (patch) | |
tree | 4f71c2429249967f3c5fe3305b7d26e4a1026e23 /transport-helper.c | |
parent | transport-helper: mark failure for atomic push (diff) | |
download | tgif-dfe1b7f19c04fd10e9bafce91bc1da0c18bbb194.tar.xz |
transport-helper: new method reject_atomic_push()
Add new method in transport-helper to reject all references if any
reference is failed for atomic push.
This method is reused in "send-pack.c" and "transport-helper.c", one for
SSH, git and file protocols, and the other for HTTP protocol.
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport-helper.c')
-rw-r--r-- | transport-helper.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/transport-helper.c b/transport-helper.c index ab3b52eb14..a46afcb69d 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -894,21 +894,7 @@ static int push_refs_with_push(struct transport *transport, case REF_STATUS_REJECT_STALE: case REF_STATUS_REJECT_ALREADY_EXISTS: if (atomic) { - /* Mark other refs as failed */ - for (ref = remote_refs; ref; ref = ref->next) { - if (!ref->peer_ref && !mirror) - continue; - - switch (ref->status) { - case REF_STATUS_NONE: - case REF_STATUS_OK: - case REF_STATUS_EXPECTING_REPORT: - ref->status = REF_STATUS_ATOMIC_PUSH_FAILED; - continue; - default: - break; /* do nothing */ - } - } + reject_atomic_push(remote_refs, mirror); string_list_clear(&cas_options, 0); return 0; } else @@ -1503,3 +1489,25 @@ int bidirectional_transfer_loop(int input, int output) return tloop_spawnwait_tasks(&state); } + +void reject_atomic_push(struct ref *remote_refs, int mirror_mode) +{ + struct ref *ref; + + /* Mark other refs as failed */ + for (ref = remote_refs; ref; ref = ref->next) { + if (!ref->peer_ref && !mirror_mode) + continue; + + switch (ref->status) { + case REF_STATUS_NONE: + case REF_STATUS_OK: + case REF_STATUS_EXPECTING_REPORT: + ref->status = REF_STATUS_ATOMIC_PUSH_FAILED; + continue; + default: + break; /* do nothing */ + } + } + return; +} |