Skip to content

Commit ac3ec0d

Browse files
sbejarJunio C Hamano
authored andcommitted
t/t5515-fetch-merge-logic.sh: Added tests for the merge login in git-fetch
Signed-off-by: Santi Béjar <sbejar@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 46d4947 commit ac3ec0d

File tree

63 files changed

+731
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+731
-0
lines changed

t/t5515-fetch-merge-logic.sh

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2007 Santi Béjar, based on t4013 by Junio C Hamano
4+
#
5+
#
6+
7+
test_description='Merge logic in fetch'
8+
9+
. ./test-lib.sh
10+
11+
LF='
12+
'
13+
14+
test_expect_success setup '
15+
GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&
16+
GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" &&
17+
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
18+
19+
echo >file original &&
20+
git add file &&
21+
git commit -a -m One &&
22+
git tag tag-one &&
23+
git tag tag-one-tree HEAD^{tree} &&
24+
git branch one &&
25+
26+
echo two >> file &&
27+
git commit -a -m Two &&
28+
git tag -a -m "Tag Two" tag-two &&
29+
git branch two &&
30+
31+
echo three >> file &&
32+
git commit -a -m Three &&
33+
git tag -a -m "Tag Three" tag-three &&
34+
git tag -a -m "Tag Three file" tag-three-file HEAD^{tree}:file &&
35+
git branch three &&
36+
37+
echo master >> file &&
38+
git commit -a -m Master &&
39+
git tag -a -m "Tag Master" tag-master &&
40+
41+
git checkout three &&
42+
43+
git clone . cloned &&
44+
cd cloned &&
45+
git config remote.origin.url ../.git/ &&
46+
47+
git config remote.config-explicit.url ../.git/ &&
48+
git config remote.config-explicit.fetch refs/heads/master:remotes/rem/master &&
49+
git config --add remote.config-explicit.fetch refs/heads/one:remotes/rem/one &&
50+
git config --add remote.config-explicit.fetch two:remotes/rem/two &&
51+
git config --add remote.config-explicit.fetch refs/heads/three:remotes/rem/three &&
52+
remotes="config-explicit" &&
53+
54+
git config remote.config-glob.url ../.git/ &&
55+
git config remote.config-glob.fetch refs/heads/*:refs/remotes/rem/* &&
56+
remotes="$remotes config-glob" &&
57+
58+
mkdir -p .git/remotes &&
59+
{
60+
echo "URL: ../.git/"
61+
echo "Pull: refs/heads/master:remotes/rem/master"
62+
echo "Pull: refs/heads/one:remotes/rem/one"
63+
echo "Pull: two:remotes/rem/two"
64+
echo "Pull: refs/heads/three:remotes/rem/three"
65+
} >.git/remotes/remote-explicit &&
66+
remotes="$remotes remote-explicit" &&
67+
68+
{
69+
echo "URL: ../.git/"
70+
echo "Pull: refs/heads/*:refs/remotes/rem/*"
71+
} >.git/remotes/remote-glob &&
72+
remotes="$remotes remote-glob" &&
73+
74+
mkdir -p .git/branches &&
75+
echo "../.git" > .git/branches/branches-default &&
76+
remotes="$remotes branches-default" &&
77+
78+
echo "../.git#one" > .git/branches/branches-one &&
79+
remotes="$remotes branches-one" &&
80+
81+
for remote in $remotes ; do
82+
git config branch.br-$remote.remote $remote &&
83+
git config branch.br-$remote-merge.remote $remote &&
84+
git config branch.br-$remote-merge.merge refs/heads/three &&
85+
git config branch.br-$remote-octopus.remote $remote &&
86+
git config branch.br-$remote-octopus.merge refs/heads/one &&
87+
git config --add branch.br-$remote-octopus.merge two &&
88+
git config --add branch.br-$remote-octopus.merge remotes/rem/three
89+
done
90+
'
91+
92+
# Merge logic depends on branch properties and Pull: or .fetch lines
93+
for remote in $remotes ; do
94+
for branch in "" "-merge" "-octopus" ; do
95+
cat <<EOF
96+
br-$remote$branch
97+
br-$remote$branch $remote
98+
EOF
99+
done
100+
done > tests
101+
102+
# Merge logic does not depend on branch properties,
103+
# but does depend on Pull: or fetch lines.
104+
# Use two branches completely unrelated from the arguments,
105+
# the clone default and one without branch properties
106+
for branch in master br-unconfig ; do
107+
echo $branch
108+
for remote in $remotes ; do
109+
echo $branch $remote
110+
done
111+
done >> tests
112+
113+
# Merge logic does not depend on branch properties
114+
# neither in the Pull: or .fetch config
115+
for branch in master br-unconfig ; do
116+
cat <<EOF
117+
$branch ../.git one
118+
$branch ../.git one two
119+
$branch --tags ../.git
120+
$branch ../.git tag tag-one tag tag-three
121+
$branch ../.git tag tag-one-tree tag tag-three-file
122+
$branch ../.git one tag tag-one tag tag-three-file
123+
EOF
124+
done >> tests
125+
126+
while read cmd
127+
do
128+
case "$cmd" in
129+
'' | '#'*) continue ;;
130+
esac
131+
test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
132+
cnt=`expr $test_count + 1`
133+
pfx=`printf "%04d" $cnt`
134+
expect="../../t5515/fetch.$test"
135+
actual="$pfx-fetch.$test"
136+
137+
test_expect_success "$cmd" '
138+
{
139+
echo "# $cmd"
140+
set x $cmd; shift
141+
git symbolic-ref HEAD refs/heads/$1 ; shift
142+
rm -f .git/FETCH_HEAD
143+
rm -f .git/refs/heads/*
144+
rm -f .git/refs/remotes/rem/*
145+
rm -f .git/refs/tags/*
146+
git fetch "$@" >/dev/null
147+
cat .git/FETCH_HEAD
148+
} >"$actual" &&
149+
if test -f "$expect"
150+
then
151+
diff -u "$expect" "$actual" &&
152+
rm -f "$actual"
153+
else
154+
# this is to help developing new tests.
155+
cp "$actual" "$expect"
156+
false
157+
fi
158+
'
159+
done < tests
160+
161+
test_done

t/t5515/fetch.br-branches-default

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# br-branches-default
2+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../
3+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../
4+
8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../
5+
22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../
6+
0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../
7+
0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../
8+
6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# br-branches-default-merge
2+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../
3+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../
4+
8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../
5+
22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../
6+
0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../
7+
0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../
8+
6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# br-branches-default-merge branches-default
2+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../
3+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../
4+
8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../
5+
22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../
6+
0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../
7+
0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../
8+
6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# br-branches-default-octopus
2+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../
3+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../
4+
8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../
5+
22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../
6+
0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../
7+
0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../
8+
6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# br-branches-default-octopus branches-default
2+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../
3+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../
4+
8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../
5+
22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../
6+
0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../
7+
0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../
8+
6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# br-branches-default branches-default
2+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f branch 'master' of ../
3+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../
4+
8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../
5+
22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../
6+
0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../
7+
0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../
8+
6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../

t/t5515/fetch.br-branches-one

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# br-branches-one
2+
8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../
3+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../
4+
8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../
5+
22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../
6+
0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../
7+
0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../
8+
6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# br-branches-one-merge
2+
8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../
3+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../
4+
8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../
5+
22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../
6+
0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../
7+
0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../
8+
6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# br-branches-one-merge branches-one
2+
8e32a6d901327a23ef831511badce7bf3bf46689 branch 'one' of ../
3+
754b754407bf032e9a2f9d5a9ad05ca79a6b228f not-for-merge tag 'tag-master' of ../
4+
8e32a6d901327a23ef831511badce7bf3bf46689 not-for-merge tag 'tag-one' of ../
5+
22feea448b023a2d864ef94b013735af34d238ba not-for-merge tag 'tag-one-tree' of ../
6+
0567da4d5edd2ff4bb292a465ba9e64dcad9536b not-for-merge tag 'tag-three' of ../
7+
0e3b14047d3ee365f4f2a1b673db059c3972589c not-for-merge tag 'tag-three-file' of ../
8+
6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 not-for-merge tag 'tag-two' of ../

0 commit comments

Comments
 (0)