]> git.ipfire.org Git - thirdparty/git.git/blame - git-remote-testgit
transport-helper: pass --signed-tags=warn-strip to fast-export
[thirdparty/git.git] / git-remote-testgit
CommitLineData
fc407f98
FC
1#!/usr/bin/env bash
2# Copyright (c) 2012 Felipe Contreras
3
4alias=$1
5url=$2
6
fc407f98
FC
7dir="$GIT_DIR/testgit/$alias"
8prefix="refs/testgit/$alias"
fc407f98 9
ee10fbf9
FC
10default_refspec="refs/heads/*:${prefix}/heads/*"
11
12refspec="${GIT_REMOTE_TESTGIT_REFSPEC-$default_refspec}"
13
14test -z "$refspec" && prefix="refs"
fc407f98
FC
15
16export GIT_DIR="$url/.git"
17
18mkdir -p "$dir"
19
ee10fbf9
FC
20if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
21then
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" )
27fi
fc407f98
FC
28
29while read line
30do
31 case $line in
32 capabilities)
33 echo 'import'
34 echo 'export'
ee10fbf9
FC
35 test -n "$refspec" && echo "refspec $refspec"
36 if test -n "$gitmarks"
37 then
38 echo "*import-marks $gitmarks"
39 echo "*export-marks $gitmarks"
40 fi
fc407f98
FC
41 echo
42 ;;
43 list)
44 git for-each-ref --format='? %(refname)' 'refs/heads/'
45 head=$(git symbolic-ref HEAD)
46 echo "@$head HEAD"
47 echo
48 ;;
49 import*)
50 # read all import lines
51 while true
52 do
53 ref="${line#* }"
54 refs="$refs $ref"
55 read line
56 test "${line%% *}" != "import" && break
57 done
58
ee10fbf9
FC
59 if test -n "$gitmarks"
60 then
61 echo "feature import-marks=$gitmarks"
62 echo "feature export-marks=$gitmarks"
63 fi
1d3f9a30
FC
64 echo "feature done"
65 git fast-export "${testgitmarks_args[@]}" $refs |
fc407f98 66 sed -e "s#refs/heads/#${prefix}/heads/#g"
1d3f9a30 67 echo "done"
fc407f98
FC
68 ;;
69 export)
93b5cf9c
FC
70 before=$(git for-each-ref --format='%(refname) %(objectname)')
71
ee10fbf9 72 git fast-import "${testgitmarks_args[@]}" --quiet
93b5cf9c
FC
73
74 after=$(git for-each-ref --format='%(refname) %(objectname)')
75
76 # figure out which refs were updated
77 join -e 0 -o '0 1.2 2.2' -a 2 <(echo "$before") <(echo "$after") |
78 while read ref a b
79 do
80 test $a == $b && continue
81 echo "ok $ref"
82 done
83
fc407f98
FC
84 echo
85 ;;
86 '')
87 exit
88 ;;
89 esac
90done