File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -805,7 +805,7 @@ static int push(int nr_spec, char **specs)
805
805
static void parse_push (struct strbuf * buf )
806
806
{
807
807
char * * specs = NULL ;
808
- int alloc_spec = 0 , nr_spec = 0 , i ;
808
+ int alloc_spec = 0 , nr_spec = 0 , i , ret ;
809
809
810
810
do {
811
811
if (!prefixcmp (buf -> buf , "push " )) {
@@ -822,12 +822,13 @@ static void parse_push(struct strbuf *buf)
822
822
break ;
823
823
} while (1 );
824
824
825
- if (push (nr_spec , specs ))
826
- exit (128 ); /* error already reported */
827
-
825
+ ret = push (nr_spec , specs );
828
826
printf ("\n" );
829
827
fflush (stdout );
830
828
829
+ if (ret )
830
+ exit (128 ); /* error already reported */
831
+
831
832
free_specs :
832
833
for (i = 0 ; i < nr_spec ; i ++ )
833
834
free (specs [i ]);
Original file line number Diff line number Diff line change @@ -95,6 +95,32 @@ test_expect_success 'create and delete remote branch' '
95
95
test_must_fail git show-ref --verify refs/remotes/origin/dev
96
96
'
97
97
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
+
98
124
cat > exp << EOF
99
125
100
126
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
106
132
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
107
133
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
108
134
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
109
137
EOF
110
138
test_expect_success ' used receive-pack service' '
111
139
sed -e "
You can’t perform that action at this time.
0 commit comments