Skip to content

Commit 60c208d

Browse files
pks-tgitster
authored andcommitted
t5543: atomic push reports exit code failure
Add new test cases in t5543 to avoid ignoring the exit code of git-receive-pack(1) during atomic push with "--porcelain" flag. We'd typically notice this case because the refs would have their error message set. But there is an edge case when pushing refs succeeds, but git-receive-pack(1) exits with a non-zero exit code at a later point in time due to another error. An atomic git-push(1) would ignore that error code, and consequently it would return successfully and not print any error message at all. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3028db4 commit 60c208d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

t/t5543-atomic-push.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,34 @@ test_expect_success 'atomic push reports (reject by non-ff)' '
280280
test_cmp expect actual
281281
'
282282

283+
test_expect_failure 'atomic push reports exit code failure' '
284+
write_script receive-pack-wrapper <<-\EOF &&
285+
git-receive-pack "$@"
286+
exit 1
287+
EOF
288+
test_must_fail git -C workbench push --atomic \
289+
--receive-pack="${SQ}$(pwd)${SQ}/receive-pack-wrapper" \
290+
up HEAD:refs/heads/no-conflict 2>err &&
291+
cat >expect <<-EOF &&
292+
To ../upstream
293+
* [new branch] HEAD -> no-conflict
294+
error: failed to push some refs to ${SQ}../upstream${SQ}
295+
EOF
296+
test_cmp expect err
297+
'
298+
299+
test_expect_failure 'atomic push reports exit code failure with porcelain' '
300+
write_script receive-pack-wrapper <<-\EOF &&
301+
git-receive-pack "$@"
302+
exit 1
303+
EOF
304+
test_must_fail git -C workbench push --atomic --porcelain \
305+
--receive-pack="${SQ}$(pwd)${SQ}/receive-pack-wrapper" \
306+
up HEAD:refs/heads/no-conflict-porcelain 2>err &&
307+
cat >expect <<-EOF &&
308+
error: failed to push some refs to ${SQ}../upstream${SQ}
309+
EOF
310+
test_cmp expect err
311+
'
312+
283313
test_done

0 commit comments

Comments
 (0)