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
13 dir
="$GIT_DIR/testgit/$alias"
15 h_refspec
="refs/heads/*:refs/testgit/$alias/heads/*"
16 t_refspec
="refs/tags/*:refs/testgit/$alias/tags/*"
18 if test -n "$GIT_REMOTE_TESTGIT_NOREFSPEC"
31 if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
33 gitmarks
="$dir/git.marks"
34 testgitmarks
="$dir/testgit.marks"
35 test -e "$gitmarks" ||
>"$gitmarks"
36 test -e "$testgitmarks" ||
>"$testgitmarks"
45 test -n "$h_refspec" && echo "refspec $h_refspec"
46 test -n "$t_refspec" && echo "refspec $t_refspec"
47 if test -n "$gitmarks"
49 echo "*import-marks $gitmarks"
50 echo "*export-marks $gitmarks"
52 test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
53 test -n "$GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE" && echo "no-private-update"
59 echo ":object-format $(git rev-parse --show-object-format=storage)"
60 git for-each-ref
--format='? %(refname)' 'refs/heads/' 'refs/tags/'
61 head=$
(git symbolic-ref HEAD
)
66 # read all import lines
72 test "${line%% *}" != "import" && break
75 if test -n "$gitmarks"
77 echo "feature import-marks=$gitmarks"
78 echo "feature export-marks=$gitmarks"
81 if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
89 ${h_refspec:+"--refspec=$h_refspec"} \
90 ${t_refspec:+"--refspec=$t_refspec"} \
91 ${testgitmarks:+"--import-marks=$testgitmarks"} \
92 ${testgitmarks:+"--export-marks=$testgitmarks"} \
97 if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
99 # consume input so fast-export doesn't get SIGPIPE;
100 # git would also notice that case, but we want
101 # to make sure we are exercising the later
104 test "done" = "$line" && break
109 before
=$
(git for-each-ref
--format=' %(refname) %(objectname) ')
113 ${testgitmarks:+"--import-marks=$testgitmarks"} \
114 ${testgitmarks:+"--export-marks=$testgitmarks"} \
117 # figure out which refs were updated
118 git for-each-ref
--format='%(refname) %(objectname)' |
123 continue ;; # unchanged
125 if test -z "$GIT_REMOTE_TESTGIT_PUSH_ERROR"
129 echo "error $ref $GIT_REMOTE_TESTGIT_PUSH_ERROR"
136 read cmd opt val
<<-EOF
141 test $val = "true" && force
="true" || force
=
145 test $val = "true" && object_format
="true" || object_format
=