]> git.ipfire.org Git - thirdparty/git.git/blame - git-remote-testgit
Update draft release notes for 1.8.3
[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
0d957a4d 41 test -n "$GIT_REMOTE_TESTGIT_SIGNED_TAGS" && echo "signed-tags"
fc407f98
FC
42 echo
43 ;;
44 list)
45 git for-each-ref --format='? %(refname)' 'refs/heads/'
46 head=$(git symbolic-ref HEAD)
47 echo "@$head HEAD"
48 echo
49 ;;
50 import*)
51 # read all import lines
52 while true
53 do
54 ref="${line#* }"
55 refs="$refs $ref"
56 read line
57 test "${line%% *}" != "import" && break
58 done
59
ee10fbf9
FC
60 if test -n "$gitmarks"
61 then
62 echo "feature import-marks=$gitmarks"
63 echo "feature export-marks=$gitmarks"
64 fi
1d3f9a30
FC
65 echo "feature done"
66 git fast-export "${testgitmarks_args[@]}" $refs |
fc407f98 67 sed -e "s#refs/heads/#${prefix}/heads/#g"
1d3f9a30 68 echo "done"
fc407f98
FC
69 ;;
70 export)
93b5cf9c
FC
71 before=$(git for-each-ref --format='%(refname) %(objectname)')
72
ee10fbf9 73 git fast-import "${testgitmarks_args[@]}" --quiet
93b5cf9c
FC
74
75 after=$(git for-each-ref --format='%(refname) %(objectname)')
76
77 # figure out which refs were updated
78 join -e 0 -o '0 1.2 2.2' -a 2 <(echo "$before") <(echo "$after") |
79 while read ref a b
80 do
81 test $a == $b && continue
82 echo "ok $ref"
83 done
84
fc407f98
FC
85 echo
86 ;;
87 '')
88 exit
89 ;;
90 esac
91done