2 # Copyright (c) 2012 Felipe Contreras
7 dir
="$GIT_DIR/testgit/$alias"
8 prefix
="refs/testgit/$alias"
10 default_refspec
="refs/heads/*:${prefix}/heads/*"
12 refspec
="${GIT_REMOTE_TESTGIT_REFSPEC-$default_refspec}"
14 test -z "$refspec" && prefix
="refs"
16 export GIT_DIR
="$url/.git"
20 if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
22 gitmarks
="$dir/git.marks"
23 testgitmarks
="$dir/testgit.marks"
24 test -e "$gitmarks" ||
>"$gitmarks"
25 test -e "$testgitmarks" ||
>"$testgitmarks"
26 testgitmarks_args
=( "--"{import
,export}"-marks=$testgitmarks" )
35 test -n "$refspec" && echo "refspec $refspec"
36 if test -n "$gitmarks"
38 echo "*import-marks $gitmarks"
39 echo "*export-marks $gitmarks"
44 git for-each-ref
--format='? %(refname)' 'refs/heads/'
45 head=$
(git symbolic-ref HEAD
)
50 # read all import lines
56 test "${line%% *}" != "import" && break
59 if test -n "$gitmarks"
61 echo "feature import-marks=$gitmarks"
62 echo "feature export-marks=$gitmarks"
65 git fast-export
"${testgitmarks_args[@]}" $refs |
66 sed -e "s#refs/heads/#${prefix}/heads/#g"
70 before
=$
(git for-each-ref
--format='%(refname) %(objectname)')
72 git fast-import
"${testgitmarks_args[@]}" --quiet
74 after
=$
(git for-each-ref
--format='%(refname) %(objectname)')
76 # figure out which refs were updated
77 join -e 0 -o '0 1.2 2.2' -a 2 <(echo "$before") <(echo "$after") |
80 test $a == $b && continue