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 @@ -807,7 +807,7 @@ static int push(int nr_spec, char **specs)
807807static void parse_push (struct strbuf * buf )
808808{
809809 char * * specs = NULL ;
810- int alloc_spec = 0 , nr_spec = 0 , i ;
810+ int alloc_spec = 0 , nr_spec = 0 , i , ret ;
811811
812812 do {
813813 if (!prefixcmp (buf -> buf , "push " )) {
@@ -824,12 +824,13 @@ static void parse_push(struct strbuf *buf)
824824 break ;
825825 } while (1 );
826826
827- if (push (nr_spec , specs ))
828- exit (128 ); /* error already reported */
829-
827+ ret = push (nr_spec , specs );
830828 printf ("\n" );
831829 fflush (stdout );
832830
831+ if (ret )
832+ exit (128 ); /* error already reported */
833+
833834 free_specs :
834835 for (i = 0 ; i < nr_spec ; i ++ )
835836 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' '
9696 test_must_fail git show-ref --verify refs/remotes/origin/dev
9797'
9898
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+
99125cat > exp << EOF
100126
101127GET /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
107133POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
108134GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
109135POST /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
110138EOF
111139test_expect_success ' used receive-pack service' '
112140 sed -e "
You can’t perform that action at this time.
0 commit comments