Skip to content

Commit 126aac5

Browse files
felipecgitster
authored andcommitted
transport-helper: fix remote helper namespace regression
Commit 664059f (transport-helper: update remote helper namespace) updates the namespace when the push succeeds or not; we should do it only when it succeeded. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d6ae7b2 commit 126aac5

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

git-remote-testgit

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ do
9797
while read ref a b
9898
do
9999
test $a == $b && continue
100-
echo "ok $ref"
100+
if test -z "$GIT_REMOTE_TESTGIT_PUSH_ERROR"
101+
then
102+
echo "ok $ref"
103+
else
104+
echo "error $ref $GIT_REMOTE_TESTGIT_PUSH_ERROR"
105+
fi
101106
done
102107

103108
echo

t/t5801-remote-helpers.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,20 @@ test_expect_success 'push update refs' '
167167
)
168168
'
169169

170+
test_expect_success 'push update refs failure' '
171+
(cd local &&
172+
git checkout update &&
173+
echo "update fail" >>file &&
174+
git commit -a -m "update fail" &&
175+
git rev-parse --verify testgit/origin/heads/update >expect &&
176+
GIT_REMOTE_TESTGIT_PUSH_ERROR="non-fast forward" &&
177+
export GIT_REMOTE_TESTGIT_PUSH_ERROR &&
178+
test_expect_code 1 git push origin update &&
179+
git rev-parse --verify testgit/origin/heads/update >actual &&
180+
test_cmp expect actual
181+
)
182+
'
183+
170184
test_expect_success 'proper failure checks for fetching' '
171185
(GIT_REMOTE_TESTGIT_FAILURE=1 &&
172186
export GIT_REMOTE_TESTGIT_FAILURE &&

transport-helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ static int push_update_ref_status(struct strbuf *buf,
701701

702702
(*ref)->status = status;
703703
(*ref)->remote_status = msg;
704-
return 0;
704+
return !(status == REF_STATUS_OK);
705705
}
706706

707707
static void push_update_refs_status(struct helper_data *data,

0 commit comments

Comments
 (0)