Skip to content

Commit 00fb2d2

Browse files
committed
Merge branch 'cb/maint-t5541-make-server-port-portable' into maint-1.7.8
* cb/maint-t5541-make-server-port-portable: t5541: check error message against the real port number used remote-curl: Fix push status report when all branches fail
2 parents fc2d99f + d202a51 commit 00fb2d2

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

remote-curl.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ static int push(int nr_spec, char **specs)
805805
static void parse_push(struct strbuf *buf)
806806
{
807807
char **specs = NULL;
808-
int alloc_spec = 0, nr_spec = 0, i;
808+
int alloc_spec = 0, nr_spec = 0, i, ret;
809809

810810
do {
811811
if (!prefixcmp(buf->buf, "push ")) {
@@ -822,12 +822,13 @@ static void parse_push(struct strbuf *buf)
822822
break;
823823
} while (1);
824824

825-
if (push(nr_spec, specs))
826-
exit(128); /* error already reported */
827-
825+
ret = push(nr_spec, specs);
828826
printf("\n");
829827
fflush(stdout);
830828

829+
if (ret)
830+
exit(128); /* error already reported */
831+
831832
free_specs:
832833
for (i = 0; i < nr_spec; i++)
833834
free(specs[i]);

t/t5541-http-push.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,32 @@ test_expect_success 'create and delete remote branch' '
9595
test_must_fail git show-ref --verify refs/remotes/origin/dev
9696
'
9797

98+
cat >"$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" <<EOF
99+
#!/bin/sh
100+
exit 1
101+
EOF
102+
chmod a+x "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
103+
104+
cat >exp <<EOF
105+
remote: error: hook declined to update refs/heads/dev2
106+
To http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git
107+
! [remote rejected] dev2 -> dev2 (hook declined)
108+
error: failed to push some refs to 'http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git'
109+
EOF
110+
111+
test_expect_success 'rejected update prints status' '
112+
cd "$ROOT_PATH"/test_repo_clone &&
113+
git checkout -b dev2 &&
114+
: >path4 &&
115+
git add path4 &&
116+
test_tick &&
117+
git commit -m dev2 &&
118+
test_must_fail git push origin dev2 2>act &&
119+
sed -e "/^remote: /s/ *$//" <act >cmp &&
120+
test_cmp exp cmp
121+
'
122+
rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
123+
98124
cat >exp <<EOF
99125
100126
GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
@@ -106,6 +132,8 @@ GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
106132
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
107133
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
108134
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
135+
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
136+
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
109137
EOF
110138
test_expect_success 'used receive-pack service' '
111139
sed -e "

0 commit comments

Comments
 (0)