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)
805805static 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 ]);
Original file line number Diff line number Diff 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+
98124cat > exp << EOF
99125
100126GET /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
106132POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
107133GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
108134POST /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
109137EOF
110138test_expect_success ' used receive-pack service' '
111139 sed -e "
You can’t perform that action at this time.
0 commit comments