]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5801/git-remote-testgit
transport-helper: send "true" value for object-format option
[thirdparty/git.git] / t / t5801 / git-remote-testgit
CommitLineData
85d501ce 1#!/bin/sh
fc407f98
FC
2# Copyright (c) 2012 Felipe Contreras
3
33cae542
MH
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.
6if test "$1" = "testgit::$2"; then
7 alias=_
8else
9 alias=$1
10fi
fc407f98
FC
11url=$2
12
fc407f98 13dir="$GIT_DIR/testgit/$alias"
fc407f98 14
199f44cb
PS
15if ! git rev-parse --is-inside-git-dir
16then
17 exit 1
18fi
19
8144f09c
FC
20h_refspec="refs/heads/*:refs/testgit/$alias/heads/*"
21t_refspec="refs/tags/*:refs/testgit/$alias/tags/*"
ee10fbf9 22
8144f09c
FC
23if test -n "$GIT_REMOTE_TESTGIT_NOREFSPEC"
24then
25 h_refspec=""
26 t_refspec=""
27fi
fc407f98 28
bed137d2
EP
29GIT_DIR="$url/.git"
30export GIT_DIR
fc407f98 31
510fa6f5 32force=
b5b7b17b 33object_format=
510fa6f5 34
fc407f98
FC
35mkdir -p "$dir"
36
ee10fbf9
FC
37if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
38then
39 gitmarks="$dir/git.marks"
40 testgitmarks="$dir/testgit.marks"
41 test -e "$gitmarks" || >"$gitmarks"
42 test -e "$testgitmarks" || >"$testgitmarks"
ee10fbf9 43fi
fc407f98
FC
44
45while read line
46do
47 case $line in
48 capabilities)
49 echo 'import'
50 echo 'export'
8144f09c
FC
51 test -n "$h_refspec" && echo "refspec $h_refspec"
52 test -n "$t_refspec" && echo "refspec $t_refspec"
ee10fbf9
FC
53 if test -n "$gitmarks"
54 then
55 echo "*import-marks $gitmarks"
56 echo "*export-marks $gitmarks"
57 fi
0d957a4d 58 test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
597b831a 59 test -n "$GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE" && echo "no-private-update"
510fa6f5 60 echo 'option'
3716d50d 61 echo 'object-format'
fc407f98
FC
62 echo
63 ;;
64 list)
b5b7b17b
JK
65 test -n "$object_format" &&
66 echo ":object-format $(git rev-parse --show-object-format=storage)"
8144f09c 67 git for-each-ref --format='? %(refname)' 'refs/heads/' 'refs/tags/'
fc407f98
FC
68 head=$(git symbolic-ref HEAD)
69 echo "@$head HEAD"
70 echo
71 ;;
72 import*)
73 # read all import lines
74 while true
75 do
76 ref="${line#* }"
77 refs="$refs $ref"
78 read line
79 test "${line%% *}" != "import" && break
80 done
81
ee10fbf9
FC
82 if test -n "$gitmarks"
83 then
84 echo "feature import-marks=$gitmarks"
85 echo "feature export-marks=$gitmarks"
86 fi
81d340d4
FC
87
88 if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
89 then
90 echo "feature done"
91 exit 1
92 fi
93
1d3f9a30 94 echo "feature done"
85d501ce 95 git fast-export \
8144f09c
FC
96 ${h_refspec:+"--refspec=$h_refspec"} \
97 ${t_refspec:+"--refspec=$t_refspec"} \
85d501ce
JS
98 ${testgitmarks:+"--import-marks=$testgitmarks"} \
99 ${testgitmarks:+"--export-marks=$testgitmarks"} \
6e17fb34 100 $refs
1d3f9a30 101 echo "done"
fc407f98
FC
102 ;;
103 export)
81d340d4
FC
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
114 fi
115
752db425 116 before=$(git for-each-ref --format=' %(refname) %(objectname) ')
93b5cf9c 117
85d501ce 118 git fast-import \
510fa6f5 119 ${force:+--force} \
85d501ce
JS
120 ${testgitmarks:+"--import-marks=$testgitmarks"} \
121 ${testgitmarks:+"--export-marks=$testgitmarks"} \
122 --quiet
93b5cf9c
FC
123
124 # figure out which refs were updated
752db425
JS
125 git for-each-ref --format='%(refname) %(objectname)' |
126 while read ref a
93b5cf9c 127 do
752db425
JS
128 case "$before" in
129 *" $ref $a "*)
130 continue ;; # unchanged
131 esac
126aac5c
FC
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"
137 fi
93b5cf9c
FC
138 done
139
fc407f98
FC
140 echo
141 ;;
510fa6f5
FC
142 option\ *)
143 read cmd opt val <<-EOF
144 $line
145 EOF
146 case $opt in
147 force)
148 test $val = "true" && force="true" || force=
149 echo "ok"
150 ;;
3716d50d 151 object-format)
152 test $val = "true" && object_format="true" || object_format=
153 echo "ok"
154 ;;
510fa6f5
FC
155 *)
156 echo "unsupported"
157 ;;
158 esac
159 ;;
fc407f98
FC
160 '')
161 exit
162 ;;
163 esac
164done