File tree 2 files changed +33
-4
lines changed 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -807,7 +807,7 @@ static int push(int nr_spec, char **specs)
807
807
static void parse_push (struct strbuf * buf )
808
808
{
809
809
char * * specs = NULL ;
810
- int alloc_spec = 0 , nr_spec = 0 , i ;
810
+ int alloc_spec = 0 , nr_spec = 0 , i , ret ;
811
811
812
812
do {
813
813
if (!prefixcmp (buf -> buf , "push " )) {
@@ -824,12 +824,13 @@ static void parse_push(struct strbuf *buf)
824
824
break ;
825
825
} while (1 );
826
826
827
- if (push (nr_spec , specs ))
828
- exit (128 ); /* error already reported */
829
-
827
+ ret = push (nr_spec , specs );
830
828
printf ("\n" );
831
829
fflush (stdout );
832
830
831
+ if (ret )
832
+ exit (128 ); /* error already reported */
833
+
833
834
free_specs :
834
835
for (i = 0 ; i < nr_spec ; i ++ )
835
836
free (specs [i ]);
Original file line number Diff line number Diff line change @@ -96,6 +96,32 @@ test_expect_success 'create and delete remote branch' '
96
96
test_must_fail git show-ref --verify refs/remotes/origin/dev
97
97
'
98
98
99
+ cat > " $HTTPD_DOCUMENT_ROOT_PATH /test_repo.git/hooks/update" << EOF
100
+ #!/bin/sh
101
+ exit 1
102
+ EOF
103
+ chmod a+x " $HTTPD_DOCUMENT_ROOT_PATH /test_repo.git/hooks/update"
104
+
105
+ cat > exp << EOF
106
+ remote: error: hook declined to update refs/heads/dev2
107
+ To http://127.0.0.1:$LIB_HTTPD_PORT /smart/test_repo.git
108
+ ! [remote rejected] dev2 -> dev2 (hook declined)
109
+ error: failed to push some refs to 'http://127.0.0.1:5541/smart/test_repo.git'
110
+ EOF
111
+
112
+ test_expect_success ' rejected update prints status' '
113
+ cd "$ROOT_PATH"/test_repo_clone &&
114
+ git checkout -b dev2 &&
115
+ : >path4 &&
116
+ git add path4 &&
117
+ test_tick &&
118
+ git commit -m dev2 &&
119
+ test_must_fail git push origin dev2 2>act &&
120
+ sed -e "/^remote: /s/ *$//" <act >cmp &&
121
+ test_cmp exp cmp
122
+ '
123
+ rm -f " $HTTPD_DOCUMENT_ROOT_PATH /test_repo.git/hooks/update"
124
+
99
125
cat > exp << EOF
100
126
101
127
GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
@@ -107,6 +133,8 @@ GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
107
133
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
108
134
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
109
135
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
136
+ GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
137
+ POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
110
138
EOF
111
139
test_expect_success ' used receive-pack service' '
112
140
sed -e "
You can’t perform that action at this time.
0 commit comments