]>
Commit | Line | Data |
---|---|---|
fc407f98 FC |
1 | #!/usr/bin/env bash |
2 | # Copyright (c) 2012 Felipe Contreras | |
3 | ||
4 | alias=$1 | |
5 | url=$2 | |
6 | ||
7 | # huh? | |
8 | url="${url#file://}" | |
9 | ||
10 | dir="$GIT_DIR/testgit/$alias" | |
11 | prefix="refs/testgit/$alias" | |
12 | refspec="refs/heads/*:${prefix}/heads/*" | |
13 | ||
14 | gitmarks="$dir/git.marks" | |
15 | testgitmarks="$dir/testgit.marks" | |
16 | ||
17 | export GIT_DIR="$url/.git" | |
18 | ||
19 | mkdir -p "$dir" | |
20 | ||
21 | test -e "$gitmarks" || > "$gitmarks" | |
22 | test -e "$testgitmarks" || > "$testgitmarks" | |
23 | ||
24 | while read line | |
25 | do | |
26 | case $line in | |
27 | capabilities) | |
28 | echo 'import' | |
29 | echo 'export' | |
30 | echo "refspec $refspec" | |
31 | echo "*import-marks $gitmarks" | |
32 | echo "*export-marks $gitmarks" | |
33 | echo | |
34 | ;; | |
35 | list) | |
36 | git for-each-ref --format='? %(refname)' 'refs/heads/' | |
37 | head=$(git symbolic-ref HEAD) | |
38 | echo "@$head HEAD" | |
39 | echo | |
40 | ;; | |
41 | import*) | |
42 | # read all import lines | |
43 | while true | |
44 | do | |
45 | ref="${line#* }" | |
46 | refs="$refs $ref" | |
47 | read line | |
48 | test "${line%% *}" != "import" && break | |
49 | done | |
50 | ||
51 | echo "feature import-marks=$gitmarks" | |
52 | echo "feature export-marks=$gitmarks" | |
53 | git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs | | |
54 | sed -e "s#refs/heads/#${prefix}/heads/#g" | |
55 | ;; | |
56 | export) | |
57 | git fast-import --{import,export}-marks="$testgitmarks" --quiet | |
58 | echo | |
59 | ;; | |
60 | '') | |
61 | exit | |
62 | ;; | |
63 | esac | |
64 | done |