]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5801/git-remote-testgit
reftable/block: avoid decoding keys when searching restart points
[thirdparty/git.git] / t / t5801 / git-remote-testgit
1 #!/bin/sh
2 # Copyright (c) 2012 Felipe Contreras
3
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
10 fi
11 url=$2
12
13 dir="$GIT_DIR/testgit/$alias"
14
15 if ! git rev-parse --is-inside-git-dir
16 then
17 exit 1
18 fi
19
20 h_refspec="refs/heads/*:refs/testgit/$alias/heads/*"
21 t_refspec="refs/tags/*:refs/testgit/$alias/tags/*"
22
23 if test -n "$GIT_REMOTE_TESTGIT_NOREFSPEC"
24 then
25 h_refspec=""
26 t_refspec=""
27 fi
28
29 GIT_DIR="$url/.git"
30 export GIT_DIR
31
32 force=
33
34 mkdir -p "$dir"
35
36 if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
37 then
38 gitmarks="$dir/git.marks"
39 testgitmarks="$dir/testgit.marks"
40 test -e "$gitmarks" || >"$gitmarks"
41 test -e "$testgitmarks" || >"$testgitmarks"
42 fi
43
44 while read line
45 do
46 case $line in
47 capabilities)
48 echo 'import'
49 echo 'export'
50 test -n "$h_refspec" && echo "refspec $h_refspec"
51 test -n "$t_refspec" && echo "refspec $t_refspec"
52 if test -n "$gitmarks"
53 then
54 echo "*import-marks $gitmarks"
55 echo "*export-marks $gitmarks"
56 fi
57 test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
58 test -n "$GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE" && echo "no-private-update"
59 echo 'option'
60 echo 'object-format'
61 echo
62 ;;
63 list)
64 echo ":object-format $(git rev-parse --show-object-format=storage)"
65 git for-each-ref --format='? %(refname)' 'refs/heads/' 'refs/tags/'
66 head=$(git symbolic-ref HEAD)
67 echo "@$head HEAD"
68 echo
69 ;;
70 import*)
71 # read all import lines
72 while true
73 do
74 ref="${line#* }"
75 refs="$refs $ref"
76 read line
77 test "${line%% *}" != "import" && break
78 done
79
80 if test -n "$gitmarks"
81 then
82 echo "feature import-marks=$gitmarks"
83 echo "feature export-marks=$gitmarks"
84 fi
85
86 if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
87 then
88 echo "feature done"
89 exit 1
90 fi
91
92 echo "feature done"
93 git fast-export \
94 ${h_refspec:+"--refspec=$h_refspec"} \
95 ${t_refspec:+"--refspec=$t_refspec"} \
96 ${testgitmarks:+"--import-marks=$testgitmarks"} \
97 ${testgitmarks:+"--export-marks=$testgitmarks"} \
98 $refs
99 echo "done"
100 ;;
101 export)
102 if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
103 then
104 # consume input so fast-export doesn't get SIGPIPE;
105 # git would also notice that case, but we want
106 # to make sure we are exercising the later
107 # error checks
108 while read line; do
109 test "done" = "$line" && break
110 done
111 exit 1
112 fi
113
114 before=$(git for-each-ref --format=' %(refname) %(objectname) ')
115
116 git fast-import \
117 ${force:+--force} \
118 ${testgitmarks:+"--import-marks=$testgitmarks"} \
119 ${testgitmarks:+"--export-marks=$testgitmarks"} \
120 --quiet
121
122 # figure out which refs were updated
123 git for-each-ref --format='%(refname) %(objectname)' |
124 while read ref a
125 do
126 case "$before" in
127 *" $ref $a "*)
128 continue ;; # unchanged
129 esac
130 if test -z "$GIT_REMOTE_TESTGIT_PUSH_ERROR"
131 then
132 echo "ok $ref"
133 else
134 echo "error $ref $GIT_REMOTE_TESTGIT_PUSH_ERROR"
135 fi
136 done
137
138 echo
139 ;;
140 option\ *)
141 read cmd opt val <<-EOF
142 $line
143 EOF
144 case $opt in
145 force)
146 test $val = "true" && force="true" || force=
147 echo "ok"
148 ;;
149 object-format)
150 test $val = "true" && object_format="true" || object_format=
151 echo "ok"
152 ;;
153 *)
154 echo "unsupported"
155 ;;
156 esac
157 ;;
158 '')
159 exit
160 ;;
161 esac
162 done