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"
14 prefix
="refs/testgit/$alias"
16 default_refspec
="refs/heads/*:${prefix}/heads/*"
18 refspec
="${GIT_REMOTE_TESTGIT_REFSPEC-$default_refspec}"
20 test -z "$refspec" && prefix
="refs"
29 if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
31 gitmarks
="$dir/git.marks"
32 testgitmarks
="$dir/testgit.marks"
33 test -e "$gitmarks" ||
>"$gitmarks"
34 test -e "$testgitmarks" ||
>"$testgitmarks"
43 test -n "$refspec" && echo "refspec $refspec"
44 if test -n "$gitmarks"
46 echo "*import-marks $gitmarks"
47 echo "*export-marks $gitmarks"
49 test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
50 test -n "$GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE" && echo "no-private-update"
55 git for-each-ref
--format='? %(refname)' 'refs/heads/'
56 head=$
(git symbolic-ref HEAD
)
61 # read all import lines
67 test "${line%% *}" != "import" && break
70 if test -n "$gitmarks"
72 echo "feature import-marks=$gitmarks"
73 echo "feature export-marks=$gitmarks"
76 if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
84 ${testgitmarks:+"--import-marks=$testgitmarks"} \
85 ${testgitmarks:+"--export-marks=$testgitmarks"} \
87 sed -e "s#refs/heads/#${prefix}/heads/#g"
91 if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
93 # consume input so fast-export doesn't get SIGPIPE;
94 # git would also notice that case, but we want
95 # to make sure we are exercising the later
98 test "done" = "$line" && break
103 before
=$
(git for-each-ref
--format=' %(refname) %(objectname) ')
107 ${testgitmarks:+"--import-marks=$testgitmarks"} \
108 ${testgitmarks:+"--export-marks=$testgitmarks"} \
111 # figure out which refs were updated
112 git for-each-ref
--format='%(refname) %(objectname)' |
117 continue ;; # unchanged
119 if test -z "$GIT_REMOTE_TESTGIT_PUSH_ERROR"
123 echo "error $ref $GIT_REMOTE_TESTGIT_PUSH_ERROR"
130 read cmd opt val
<<-EOF
135 test $val = "true" && force
="true" || force
=