3 # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
6 test_description
='test smart pushing over http via http-backend'
9 if test -n "$NO_CURL"; then
10 say
'skipping test, git built without http support'
15 LIB_HTTPD_PORT
=${LIB_HTTPD_PORT-'5541'}
16 .
"$TEST_DIRECTORY"/lib-httpd.sh
19 test_expect_success
'setup remote repository' '
27 git commit -m initial &&
29 git clone --bare test_repo test_repo.git &&
31 git config http.receivepack true &&
32 ORIG_HEAD=$(git rev-parse --verify HEAD) &&
34 mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
37 test_expect_success
'clone remote repository' '
39 git clone $HTTPD_URL/smart/test_repo.git test_repo_clone
42 test_expect_success
'push to remote repository' '
43 cd "$ROOT_PATH"/test_repo_clone &&
47 git commit -m path2 &&
48 HEAD=$(git rev-parse --verify HEAD) &&
50 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
51 test $HEAD = $(git rev-parse --verify HEAD))
54 test_expect_success
'push already up-to-date' '
58 test_expect_success
'create and delete remote branch' '
59 cd "$ROOT_PATH"/test_repo_clone &&
60 git checkout -b dev &&
65 git push origin dev &&
66 git push origin :dev &&
67 test_must_fail git show-ref --verify refs/remotes/origin/dev
71 GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
72 POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
73 GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
74 POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
75 GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
76 GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
77 POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
78 GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
79 POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
81 test_expect_success
'used receive-pack service' '
87 " >act <"$HTTPD_ROOT_PATH"/access.log &&
91 test_expect_success
'non-fast-forward push fails' '
92 cd "$ROOT_PATH"/test_repo_clone &&
93 git checkout master &&
94 echo "changed" > path2 &&
95 git commit -a -m path2 --amend &&
97 HEAD=$(git rev-parse --verify HEAD) &&
98 !(git push -v origin >output 2>&1) &&
99 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
100 test $HEAD != $(git rev-parse --verify HEAD))
103 test_expect_success
'non-fast-forward push show ref status' '
104 grep "^ ! \[rejected\][ ]*master -> master (non-fast-forward)$" output
107 test_expect_success
'non-fast-forward push shows help message' '
108 grep "To prevent you from losing history, non-fast-forward updates were rejected" \
112 test_expect_success
'push fails for non-fast-forward refs unmatched by remote helper' '
113 # create a dissimilarly-named remote ref so that git is unable to match the
114 # two refs (viz. local, remote) unless an explicit refspec is provided.
115 git push origin master:retsam
117 echo "change changed" > path2 &&
118 git commit -a -m path2 --amend &&
120 # push master too; this ensures there is at least one '"'push'"' command to
121 # the remote helper and triggers interaction with the helper.
122 !(git push -v origin +master master:retsam >output 2>&1) &&
124 grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output &&
125 grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output &&
127 grep "To prevent you from losing history, non-fast-forward updates were rejected" \