remote-testgit: exercise more features
Unfortunately a lot of these tests fail. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Nov 28, 2012 at 23:11 UTC
ee10fbf90c74c14ae16a27f4bce8a2dd1704c9cb
2 files changed
+78
-12
git-remote-testgit
+26
-12
@@ -6,17 +6,25 @@ url=$2
6
7
dir="$GIT_DIR/testgit/$alias"
8
prefix="refs/testgit/$alias"
9
-refspec="refs/heads/*:${prefix}/heads/*"
9
11
-gitmarks="$dir/git.marks"
12
-testgitmarks="$dir/testgit.marks"
10
+default_refspec="refs/heads/*:${prefix}/heads/*"
11
+
12
+refspec="${GIT_REMOTE_TESTGIT_REFSPEC-$default_refspec}"
13
+
14
+test -z "$refspec" && prefix="refs"
15
16
export GIT_DIR="$url/.git"
17
18
mkdir -p "$dir"
19
18
-test -e "$gitmarks" || > "$gitmarks"
19
-test -e "$testgitmarks" || > "$testgitmarks"
20
+if test -z "$GIT_REMOTE_TESTGIT_NO_MARKS"
21
+then
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" )
27
+fi
28
29
while read line
30
do
@@ -24,9 +32,12 @@ do
32
capabilities)
33
echo 'import'
34
echo 'export'
27
- echo "refspec $refspec"
28
- echo "*import-marks $gitmarks"
29
- echo "*export-marks $gitmarks"
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
41
echo
42
;;
43
list)
@@ -45,13 +56,16 @@ do
56
test "${line%% *}" != "import" && break
57
done
58
48
- echo "feature import-marks=$gitmarks"
49
- echo "feature export-marks=$gitmarks"
50
- git fast-export --use-done-feature --{import,export}-marks="$testgitmarks" $refs |
59
+ if test -n "$gitmarks"
60
+ then
61
+ echo "feature import-marks=$gitmarks"
62
+ echo "feature export-marks=$gitmarks"
63
+ fi
64
+ git fast-export --use-done-feature "${testgitmarks_args[@]}" $refs |
65
sed -e "s#refs/heads/#${prefix}/heads/#g"
66
;;
67
export)
54
- git fast-import --{import,export}-marks="$testgitmarks" --quiet
68
+ git fast-import "${testgitmarks_args[@]}" --quiet
69
echo
70
;;
71
'')
t/t5801-remote-helpers.sh
+52
@@ -110,4 +110,56 @@ test_expect_failure 'push new branch with old:new refspec' '
110
compare_refs local HEAD server refs/heads/new-refspec
111
'
112
113
+test_expect_success 'cloning without refspec' '
114
+ GIT_REMOTE_TESTGIT_REFSPEC="" \
115
+ git clone "testgit::${PWD}/server" local2 &&
116
+ compare_refs local2 HEAD server HEAD
117
+'
118
+
119
+test_expect_success 'pulling without refspecs' '
120
+ (cd local2 &&
121
+ git reset --hard &&
122
+ GIT_REMOTE_TESTGIT_REFSPEC="" git pull) &&
123
+ compare_refs local2 HEAD server HEAD
124
+'
125
+
126
+test_expect_failure 'pushing without refspecs' '
127
+ test_when_finished "(cd local2 && git reset --hard origin)" &&
128
+ (cd local2 &&
129
+ echo content >>file &&
130
+ git commit -a -m ten &&
131
+ GIT_REMOTE_TESTGIT_REFSPEC="" git push) &&
132
+ compare_refs local2 HEAD server HEAD
133
+'
134
+
135
+test_expect_success 'pulling with straight refspec' '
136
+ (cd local2 &&
137
+ GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
138
+ compare_refs local2 HEAD server HEAD
139
+'
140
+
141
+test_expect_failure 'pushing with straight refspec' '
142
+ test_when_finished "(cd local2 && git reset --hard origin)" &&
143
+ (cd local2 &&
144
+ echo content >>file &&
145
+ git commit -a -m eleven &&
146
+ GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
147
+ compare_refs local2 HEAD server HEAD
148
+'
149
+
150
+test_expect_success 'pulling without marks' '
151
+ (cd local2 &&
152
+ GIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) &&
153
+ compare_refs local2 HEAD server HEAD
154
+'
155
+
156
+test_expect_failure 'pushing without marks' '
157
+ test_when_finished "(cd local2 && git reset --hard origin)" &&
158
+ (cd local2 &&
159
+ echo content >>file &&
160
+ git commit -a -m twelve &&
161
+ GIT_REMOTE_TESTGIT_NO_MARKS=1 git push) &&
162
+ compare_refs local2 HEAD server HEAD
163
+'
164
+
165
test_done