3 test_description='pushing to a repository using push options'
8 rm -rf workbench upstream &&
9 test_create_repo upstream &&
10 test_create_repo workbench &&
13 git config receive.denyCurrentBranch warn &&
14 mkdir -p .git/hooks &&
15 cat >.git/hooks/pre-receive <<-'EOF' &&
17 if test -n "$GIT_PUSH_OPTION_COUNT"; then
19 >hooks/pre-receive.push_options
20 while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"; do
21 eval "value=\$GIT_PUSH_OPTION_$i"
22 echo $value >>hooks/pre-receive.push_options
27 chmod u+x .git/hooks/pre-receive
29 cat >.git/hooks/post-receive <<-'EOF' &&
31 if test -n "$GIT_PUSH_OPTION_COUNT"; then
33 >hooks/post-receive.push_options
34 while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"; do
35 eval "value=\$GIT_PUSH_OPTION_$i"
36 echo $value >>hooks/post-receive.push_options
41 chmod u+x .git/hooks/post-receive
45 git remote add up ../upstream
49 # Compare the ref ($1) in upstream with a ref value from workbench ($2)
50 # i.e. test_refs second HEAD@{2}
53 git -C upstream rev-parse --verify "$1" >expect &&
54 git -C workbench rev-parse --verify "$2" >actual &&
55 test_cmp expect actual
58 test_expect_success 'one push option works for a single branch' '
60 git -C upstream config receive.advertisePushOptions true &&
64 git push --mirror up &&
66 git push --push-option=asdf up master
68 test_refs master master &&
69 echo "asdf" >expect &&
70 test_cmp expect upstream/.git/hooks/pre-receive.push_options &&
71 test_cmp expect upstream/.git/hooks/post-receive.push_options
74 test_expect_success 'push option denied by remote' '
76 git -C upstream config receive.advertisePushOptions false &&
80 git push --mirror up &&
82 test_must_fail git push --push-option=asdf up master
84 test_refs master HEAD@{1}
87 test_expect_success 'two push options work' '
89 git -C upstream config receive.advertisePushOptions true &&
93 git push --mirror up &&
95 git push --push-option=asdf --push-option="more structured text" up master
97 test_refs master master &&
98 printf "asdf\nmore structured text\n" >expect &&
99 test_cmp expect upstream/.git/hooks/pre-receive.push_options &&
100 test_cmp expect upstream/.git/hooks/post-receive.push_options