transport-helper: send "true" value for object-format option
[alt-git.git] / t / t5801 / git-remote-testgit
blobc5b10f57751b259f297be3c4dcb673f32994017b
1 #!/bin/sh
2 # Copyright (c) 2012 Felipe Contreras
4 # The first argument can be a url when the fetch/push command was a url
5 # instead of a configured remote. In this case, use a generic alias.
6 if test "$1" = "testgit::$2"; then
7 alias=_
8 else
9 alias=$1
11 url=$2
13 dir="$GIT_DIR/testgit/$alias"
15 if ! git rev-parse --is-inside-git-dir
16 then
17 exit 1
20 h_refspec="refs/heads/*:refs/testgit/$alias/heads/*"
21 t_refspec="refs/tags/*:refs/testgit/$alias/tags/*"
23 if test -n "$GIT_REMOTE_TESTGIT_NOREFSPEC"
24 then
25 h_refspec=""
26 t_refspec=""
29 GIT_DIR="$url/.git"
30 export GIT_DIR
32 force=
33 object_format=
35 mkdir -p "$dir"
37 if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
38 then
39 gitmarks="$dir/git.marks"
40 testgitmarks="$dir/testgit.marks"
41 test -e "$gitmarks" || >"$gitmarks"
42 test -e "$testgitmarks" || >"$testgitmarks"
45 while read line
47 case $line in
48 capabilities)
49 echo 'import'
50 echo 'export'
51 test -n "$h_refspec" && echo "refspec $h_refspec"
52 test -n "$t_refspec" && echo "refspec $t_refspec"
53 if test -n "$gitmarks"
54 then
55 echo "*import-marks $gitmarks"
56 echo "*export-marks $gitmarks"
58 test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
59 test -n "$GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE" && echo "no-private-update"
60 echo 'option'
61 echo 'object-format'
62 echo
64 list)
65 test -n "$object_format" &&
66 echo ":object-format $(git rev-parse --show-object-format=storage)"
67 git for-each-ref --format='? %(refname)' 'refs/heads/' 'refs/tags/'
68 head=$(git symbolic-ref HEAD)
69 echo "@$head HEAD"
70 echo
72 import*)
73 # read all import lines
74 while true
76 ref="${line#* }"
77 refs="$refs $ref"
78 read line
79 test "${line%% *}" != "import" && break
80 done
82 if test -n "$gitmarks"
83 then
84 echo "feature import-marks=$gitmarks"
85 echo "feature export-marks=$gitmarks"
88 if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
89 then
90 echo "feature done"
91 exit 1
94 echo "feature done"
95 git fast-export \
96 ${h_refspec:+"--refspec=$h_refspec"} \
97 ${t_refspec:+"--refspec=$t_refspec"} \
98 ${testgitmarks:+"--import-marks=$testgitmarks"} \
99 ${testgitmarks:+"--export-marks=$testgitmarks"} \
100 $refs
101 echo "done"
103 export)
104 if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
105 then
106 # consume input so fast-export doesn't get SIGPIPE;
107 # git would also notice that case, but we want
108 # to make sure we are exercising the later
109 # error checks
110 while read line; do
111 test "done" = "$line" && break
112 done
113 exit 1
116 before=$(git for-each-ref --format=' %(refname) %(objectname) ')
118 git fast-import \
119 ${force:+--force} \
120 ${testgitmarks:+"--import-marks=$testgitmarks"} \
121 ${testgitmarks:+"--export-marks=$testgitmarks"} \
122 --quiet
124 # figure out which refs were updated
125 git for-each-ref --format='%(refname) %(objectname)' |
126 while read ref a
128 case "$before" in
129 *" $ref $a "*)
130 continue ;; # unchanged
131 esac
132 if test -z "$GIT_REMOTE_TESTGIT_PUSH_ERROR"
133 then
134 echo "ok $ref"
135 else
136 echo "error $ref $GIT_REMOTE_TESTGIT_PUSH_ERROR"
138 done
140 echo
142 option\ *)
143 read cmd opt val <<-EOF
144 $line
146 case $opt in
147 force)
148 test $val = "true" && force="true" || force=
149 echo "ok"
151 object-format)
152 test $val = "true" && object_format="true" || object_format=
153 echo "ok"
156 echo "unsupported"
158 esac
161 exit
163 esac
164 done