remote-testgit: remove non-local functionality
[git/mingw.git] / git-remote-testgit
blob5117ab5fe0ac479672112aab60c8453e7e74866b
1 #!/usr/bin/env bash
2 # Copyright (c) 2012 Felipe Contreras
4 alias=$1
5 url=$2
7 dir="$GIT_DIR/testgit/$alias"
8 prefix="refs/testgit/$alias"
9 refspec="refs/heads/*:${prefix}/heads/*"
11 gitmarks="$dir/git.marks"
12 testgitmarks="$dir/testgit.marks"
14 export GIT_DIR="$url/.git"
16 mkdir -p "$dir"
18 test -e "$gitmarks" || > "$gitmarks"
19 test -e "$testgitmarks" || > "$testgitmarks"
21 while read line
23 case $line in
24 capabilities)
25 echo 'import'
26 echo 'export'
27 echo "refspec $refspec"
28 echo "*import-marks $gitmarks"
29 echo "*export-marks $gitmarks"
30 echo
32 list)
33 git for-each-ref --format='? %(refname)' 'refs/heads/'
34 head=$(git symbolic-ref HEAD)
35 echo "@$head HEAD"
36 echo
38 import*)
39 # read all import lines
40 while true
42 ref="${line#* }"
43 refs="$refs $ref"
44 read line
45 test "${line%% *}" != "import" && break
46 done
48 echo "feature import-marks=$gitmarks"
49 echo "feature export-marks=$gitmarks"
50 git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs |
51 sed -e "s#refs/heads/#${prefix}/heads/#g"
53 export)
54 git fast-import --{import,export}-marks="$testgitmarks" --quiet
55 echo
57 '')
58 exit
60 esac
61 done