Quick test script for generating reasonably complex merge scenarios.
Avery Pennarun committed
Apr 24, 2009 at 21:35 UTC
847e868167eb0e8a270004cbccec4ae36db06626
2 files changed
+99
-2
git-subtree.sh
+3
-2
@@ -149,6 +149,7 @@ copy_commit()
149
GIT_COMMITTER_NAME \
150
GIT_COMMITTER_EMAIL \
151
GIT_COMMITTER_DATE
152
+ (echo -n '*'; cat ) | # FIXME
153
git commit-tree "$2" $3 # reads the rest of stdin
154
) || die "Can't copy commit $1"
155
}
@@ -199,7 +200,7 @@ cmd_split()
200
cache_setup || exit $?
201
202
if [ -n "$onto" ]; then
202
- echo "Reading history for --onto=$onto..."
203
+ debug "Reading history for --onto=$onto..."
204
git rev-list $onto |
205
while read rev; do
206
# the 'onto' history is already just the subdir, so
@@ -254,7 +255,7 @@ cmd_split()
255
latest_old=$(cache_get latest_old)
256
git merge -s ours \
257
-m "$(merge_msg $dir $latest_old $latest_new)" \
257
- $latest_new
258
+ $latest_new >&2
259
fi
260
echo $latest_new
261
exit 0
test.sh
new
+96
@@ -0,0 +1,96 @@
1
+#!/bin/bash -x
2
+. shellopts.sh
3
+set -e
4
+
5
+rm -rf mainline subproj
6
+mkdir mainline subproj
7
+
8
+cd subproj
9
+git init
10
+
11
+touch sub1
12
+git add sub1
13
+git commit -m 'sub-1'
14
+git branch sub1
15
+git branch -m master subproj
16
+
17
+touch sub2
18
+git add sub2
19
+git commit -m 'sub-2'
20
+git branch sub2
21
+
22
+touch sub3
23
+git add sub3
24
+git commit -m 'sub-3'
25
+git branch sub3
26
+
27
+cd ../mainline
28
+git init
29
+touch main1
30
+git add main1
31
+git commit -m 'main-1'
32
+git branch -m master mainline
33
+
34
+git fetch ../subproj sub1
35
+git branch sub1 FETCH_HEAD
36
+git read-tree --prefix=subdir FETCH_HEAD
37
+git checkout subdir
38
+git commit -m 'initial-subdir-merge'
39
+
40
+git merge -m 'merge -s -ours' -s ours FETCH_HEAD
41
+
42
+touch subdir/main-sub3
43
+git add subdir/main-sub3
44
+git commit -m 'main-sub3'
45
+
46
+touch main-2
47
+git add main-2
48
+git commit -m 'main-2 boring'
49
+
50
+touch subdir/main-sub4
51
+git add subdir/main-sub4
52
+git commit -m 'main-sub4'
53
+
54
+git fetch ../subproj sub2
55
+git branch sub2 FETCH_HEAD
56
+git merge -s subtree FETCH_HEAD
57
+git branch pre-split
58
+
59
+split1=$(git subtree split --onto FETCH_HEAD subdir --rejoin)
60
+echo "split1={$split1}"
61
+git branch split1 "$split1"
62
+
63
+touch subdir/main-sub5
64
+git add subdir/main-sub5
65
+git commit -m 'main-sub5'
66
+
67
+cd ../subproj
68
+git fetch ../mainline split1
69
+git branch split1 FETCH_HEAD
70
+git merge FETCH_HEAD
71
+
72
+touch sub6
73
+git add sub6
74
+git commit -m 'sub6'
75
+
76
+cd ../mainline
77
+split2=$(git subtree split subdir --rejoin)
78
+git branch split2 "$split2"
79
+
80
+touch subdir/main-sub7
81
+git add subdir/main-sub7
82
+git commit -m 'main-sub7'
83
+
84
+split3=$(git subtree split subdir --rejoin)
85
+git branch split3 "$split3"
86
+
87
+cd ../subproj
88
+git fetch ../mainline split3
89
+git branch split3 FETCH_HEAD
90
+git merge FETCH_HEAD
91
+git branch subproj-merge-split3
92
+
93
+cd ../mainline
94
+git fetch ../subproj subproj-merge-split3
95
+git branch subproj-merge-split3 FETCH_HEAD
96
+git merge subproj-merge-split3