Skip to content

Commit e147e96

Browse files
committed
Merge branch 'cb/receive-pack-keep-errors' into maint
* cb/receive-pack-keep-errors: do not override receive-pack errors
2 parents c7707a4 + ef7e93d commit e147e96

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

builtin/receive-pack.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,10 @@ static void check_aliased_updates(struct command *commands)
642642
}
643643
sort_string_list(&ref_list);
644644

645-
for (cmd = commands; cmd; cmd = cmd->next)
646-
check_aliased_update(cmd, &ref_list);
645+
for (cmd = commands; cmd; cmd = cmd->next) {
646+
if (!cmd->error_string)
647+
check_aliased_update(cmd, &ref_list);
648+
}
647649

648650
string_list_clear(&ref_list, 0);
649651
}
@@ -707,8 +709,10 @@ static void execute_commands(struct command *commands, const char *unpacker_erro
707709
set_connectivity_errors(commands);
708710

709711
if (run_receive_hook(commands, pre_receive_hook, 0)) {
710-
for (cmd = commands; cmd; cmd = cmd->next)
711-
cmd->error_string = "pre-receive hook declined";
712+
for (cmd = commands; cmd; cmd = cmd->next) {
713+
if (!cmd->error_string)
714+
cmd->error_string = "pre-receive hook declined";
715+
}
712716
return;
713717
}
714718

@@ -717,9 +721,15 @@ static void execute_commands(struct command *commands, const char *unpacker_erro
717721
free(head_name_to_free);
718722
head_name = head_name_to_free = resolve_refdup("HEAD", sha1, 0, NULL);
719723

720-
for (cmd = commands; cmd; cmd = cmd->next)
721-
if (!cmd->skip_update)
722-
cmd->error_string = update(cmd);
724+
for (cmd = commands; cmd; cmd = cmd->next) {
725+
if (cmd->error_string)
726+
continue;
727+
728+
if (cmd->skip_update)
729+
continue;
730+
731+
cmd->error_string = update(cmd);
732+
}
723733
}
724734

725735
static struct command *read_head_info(void)

t/t5504-fetch-receive-strict.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ test_expect_success 'fetch with transfer.fsckobjects' '
5858
)
5959
'
6060

61+
cat >exp <<EOF
62+
To dst
63+
! refs/heads/master:refs/heads/test [remote rejected] (missing necessary objects)
64+
EOF
65+
6166
test_expect_success 'push without strict' '
6267
rm -rf dst &&
6368
git init dst &&
@@ -66,7 +71,8 @@ test_expect_success 'push without strict' '
6671
git config fetch.fsckobjects false &&
6772
git config transfer.fsckobjects false
6873
) &&
69-
git push dst master:refs/heads/test
74+
test_must_fail git push --porcelain dst master:refs/heads/test >act &&
75+
test_cmp exp act
7076
'
7177

7278
test_expect_success 'push with !receive.fsckobjects' '
@@ -77,9 +83,15 @@ test_expect_success 'push with !receive.fsckobjects' '
7783
git config receive.fsckobjects false &&
7884
git config transfer.fsckobjects true
7985
) &&
80-
git push dst master:refs/heads/test
86+
test_must_fail git push --porcelain dst master:refs/heads/test >act &&
87+
test_cmp exp act
8188
'
8289

90+
cat >exp <<EOF
91+
To dst
92+
! refs/heads/master:refs/heads/test [remote rejected] (n/a (unpacker error))
93+
EOF
94+
8395
test_expect_success 'push with receive.fsckobjects' '
8496
rm -rf dst &&
8597
git init dst &&
@@ -88,7 +100,8 @@ test_expect_success 'push with receive.fsckobjects' '
88100
git config receive.fsckobjects true &&
89101
git config transfer.fsckobjects false
90102
) &&
91-
test_must_fail git push dst master:refs/heads/test
103+
test_must_fail git push --porcelain dst master:refs/heads/test >act &&
104+
test_cmp exp act
92105
'
93106

94107
test_expect_success 'push with transfer.fsckobjects' '
@@ -98,7 +111,8 @@ test_expect_success 'push with transfer.fsckobjects' '
98111
cd dst &&
99112
git config transfer.fsckobjects true
100113
) &&
101-
test_must_fail git push dst master:refs/heads/test
114+
test_must_fail git push --porcelain dst master:refs/heads/test >act &&
115+
test_cmp exp act
102116
'
103117

104118
test_done

0 commit comments

Comments
 (0)