Skip to content

Commit c544568

Browse files
committed
Merge branch 'ps/send-pack-unhide-error-in-atomic-push' into seen
"git push --atomic --porcelain" used to ignore failures from the other side, losing the error status from the child process, which has been corrected. * ps/send-pack-unhide-error-in-atomic-push: push: not send push-options to server with --dry-run push: only ignore finish_connect() for dry-run mode t5543: atomic push reports exit code failure t5504: modernize test by moving heredocs into test bodies push: fix the behavior of the Done message for porcelain t5548: new test cases for push --porcelain and --dry-run
2 parents 5006b1c + bccc0f3 commit c544568

17 files changed

+316
-141
lines changed

send-pack.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ int send_pack(struct send_pack_args *args,
630630
reject_atomic_push(remote_refs, args->send_mirror);
631631
error("atomic push failed for ref %s. status: %d",
632632
ref->name, ref->status);
633-
ret = args->porcelain ? 0 : -1;
633+
ret = (args->porcelain && args->dry_run) ? 0 : -1;
634634
goto out;
635635
}
636636
/* else fallthrough */
@@ -678,7 +678,7 @@ int send_pack(struct send_pack_args *args,
678678
}
679679
}
680680

681-
if (use_push_options) {
681+
if (use_push_options && !args->dry_run) {
682682
struct string_list_item *item;
683683

684684
packet_buf_flush(&req_buf);
@@ -760,11 +760,12 @@ int send_pack(struct send_pack_args *args,
760760

761761
if (ret < 0)
762762
goto out;
763-
764-
if (args->porcelain) {
765-
ret = 0;
763+
else if (args->porcelain && args->dry_run)
764+
/*
765+
* Knowing a ref will be rejected in a --dry-run does not
766+
* count as an error.
767+
*/
766768
goto out;
767-
}
768769

769770
for (ref = remote_refs; ref; ref = ref->next) {
770771
switch (ref->status) {

t/t5411/test-0001-standard-git-push--porcelain.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" '
7373
> To <URL/of/upstream.git>
7474
> <COMMIT-B>:refs/heads/next <COMMIT-A>..<COMMIT-B>
7575
> ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
76-
> Done
7776
EOF
7877
test_cmp expect actual &&
7978

t/t5411/test-0003-pre-receive-declined--porcelain.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ test_expect_success "git-push is declined ($PROTOCOL/porcelain)" '
1818
> To <URL/of/upstream.git>
1919
> ! <COMMIT-B>:refs/heads/main [remote rejected] (pre-receive hook declined)
2020
> ! HEAD:refs/heads/next [remote rejected] (pre-receive hook declined)
21-
Done
2221
EOF
2322
test_cmp expect actual &&
2423

t/t5411/test-0012-no-hook-error--porcelain.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL/
1717
> To <URL/of/upstream.git>
1818
> * HEAD:refs/heads/next [new branch]
1919
> ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
20-
Done
2120
EOF
2221
test_cmp expect actual &&
2322
@@ -52,7 +51,6 @@ test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCO
5251
> ! <COMMIT-B>:refs/heads/main [remote rejected] (fail to run proc-receive hook)
5352
> ! HEAD:refs/heads/next [remote rejected] (fail to run proc-receive hook)
5453
> ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
55-
> Done
5654
EOF
5755
test_cmp expect actual &&
5856

t/t5411/test-0014-bad-protocol--porcelain.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porc
2121
cat >expect <<-EOF &&
2222
To <URL/of/upstream.git>
2323
! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
24-
Done
2524
EOF
2625
test_cmp expect actual-report &&
2726
@@ -59,7 +58,6 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTO
5958
cat >expect <<-EOF &&
6059
To <URL/of/upstream.git>
6160
! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
62-
Done
6361
EOF
6462
test_cmp expect actual &&
6563
grep "remote: fatal: die with the --die-read-version option" out-$test_count &&
@@ -90,7 +88,6 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROT
9088
cat >expect <<-EOF &&
9189
To <URL/of/upstream.git>
9290
! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
93-
Done
9491
EOF
9592
test_cmp expect actual &&
9693
grep "remote: fatal: die with the --die-write-version option" out-$test_count &&
@@ -121,7 +118,6 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROT
121118
cat >expect <<-EOF &&
122119
To <URL/of/upstream.git>
123120
! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
124-
Done
125121
EOF
126122
test_cmp expect actual &&
127123
grep "remote: fatal: die with the --die-read-commands option" out-$test_count &&
@@ -153,7 +149,6 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $
153149
cat >expect <<-EOF &&
154150
To <URL/of/upstream.git>
155151
! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
156-
Done
157152
EOF
158153
test_cmp expect actual &&
159154
grep "remote: fatal: die with the --die-read-push-options option" out-$test_count &&
@@ -183,7 +178,6 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTO
183178
cat >expect <<-EOF &&
184179
To <URL/of/upstream.git>
185180
! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
186-
Done
187181
EOF
188182
test_cmp expect actual &&
189183
grep "remote: fatal: die with the --die-write-report option" out-$test_count &&
@@ -219,7 +213,6 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain)
219213
> To <URL/of/upstream.git>
220214
> * HEAD:refs/heads/next [new branch]
221215
> ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status)
222-
> Done
223216
EOF
224217
test_cmp expect actual &&
225218
@@ -260,7 +253,6 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" '
260253
> remote: error: proc-receive reported incomplete status line: "ok" Z
261254
> To <URL/of/upstream.git>
262255
> ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status)
263-
> Done
264256
EOF
265257
test_cmp expect actual &&
266258
@@ -294,7 +286,6 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porce
294286
> remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic" Z
295287
> To <URL/of/upstream.git>
296288
> ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status)
297-
> Done
298289
EOF
299290
test_cmp expect actual &&
300291

t/t5411/test-0021-report-ng--porcelain.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL/por
2222
> remote: proc-receive> ng refs/for/main/topic Z
2323
> To <URL/of/upstream.git>
2424
> ! HEAD:refs/for/main/topic [remote rejected] (failed)
25-
> Done
2625
EOF
2726
test_cmp expect actual &&
2827
@@ -55,7 +54,6 @@ test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL/p
5554
> remote: proc-receive> ng refs/for/main/topic error msg Z
5655
> To <URL/of/upstream.git>
5756
> ! HEAD:refs/for/main/topic [remote rejected] (error msg)
58-
> Done
5957
EOF
6058
test_cmp expect actual &&
6159

t/t5411/test-0023-report-unexpect-ref--porcelain.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ test_expect_success "proc-receive: report unexpected ref ($PROTOCOL/porcelain)"
2828
> To <URL/of/upstream.git>
2929
> <COMMIT-B>:refs/heads/main <COMMIT-A>..<COMMIT-B>
3030
> ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status)
31-
> Done
3231
EOF
3332
test_cmp expect actual &&
3433

t/t5411/test-0025-report-unknown-ref--porcelain.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ test_expect_success "proc-receive: report unknown reference ($PROTOCOL/porcelain
2323
> remote: error: proc-receive reported status on unknown ref: refs/for/main/topic Z
2424
> To <URL/of/upstream.git>
2525
> ! HEAD:refs/for/a/b/c/my/topic [remote rejected] (proc-receive failed to report status)
26-
> Done
2726
EOF
2827
test_cmp expect actual &&
2928

t/t5411/test-0033-report-with-options--porcelain.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ test_expect_success "proc-receive: report option without matching ok ($PROTOCOL/
2525
> remote: error: proc-receive reported "option" without a matching "ok/ng" directive Z
2626
> To <URL/of/upstream.git>
2727
> ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status)
28-
> Done
2928
EOF
3029
test_cmp expect actual
3130
'

t/t5411/test-0039-report-mixed-refs--porcelain.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcel
6363
> HEAD:refs/for/main/topic <COMMIT-A>..<COMMIT-B>
6464
> ! HEAD:refs/for/next/topic1 [remote rejected] (fail to call Web API)
6565
> ! HEAD:refs/for/next/topic3 [remote rejected] (proc-receive failed to report status)
66-
> Done
6766
EOF
6867
test_cmp expect actual &&
6968

0 commit comments

Comments
 (0)