blob: c47405d9a8a7f87a767ab9c14a39287407cd21f1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/sh
# clean up working dir
git update-ref -d master
# create annotated tags out of svn tags
git for-each-ref --format='%(refname)' refs/remotes/svn/tags/* | while read tag_ref; do
tag=${tag_ref#refs/remotes/svn/tags/}
tree=$( git rev-parse "$tag_ref": )
# find the oldest ancestor for which the tree is the same
parent_ref="$tag_ref";
while [ $( git rev-parse --quiet --verify "$parent_ref"^: ) = "$tree" ]; do
parent_ref="$parent_ref"^
done
parent=$( git rev-parse "$parent_ref" );
# if this ancestor is in trunk then we can just tag it
# otherwise the tag has diverged from trunk and it's actually more like a
# branch than a tag
merge=$( git merge-base "refs/remotes/svn/trunk" $parent );
if [ "$merge" = "$parent" ]; then
target_ref=$parent
else
echo "tag has diverged: $tag"
target_ref="$tag_ref"
fi
# create an annotated tag based on the last commit in the tag, and delete the "branchy" ref for the tag
git show -s --pretty='format:%s%n%n%b' "$tag_ref" | \
perl -ne 'next if /^git-svn-id:/; $s++, next if /^\s*r\d+\@.*:.*\|/; s/^ // if $s; print' | \
env GIT_COMMITTER_NAME="$( git show -s --pretty='format:%an' "$tag_ref" )" \
GIT_COMMITTER_EMAIL="$( git show -s --pretty='format:%ae' "$tag_ref" )" \
GIT_COMMITTER_DATE="$( git show -s --pretty='format:%ad' "$tag_ref" )" \
git tag -a -F - "$tag" "$target_ref"
git update-ref -d "$tag_ref"
done
# create local branches out of svn branches
git for-each-ref --format='%(refname)' refs/remotes/svn/ | while read branch_ref; do
branch=${branch_ref#refs/remotes/svn/}
git branch "$branch" "$branch_ref"
git update-ref -d "$branch_ref"
done
# rename 'trunk' to 'master'
git checkout trunk
git branch -M trunk master
# remove merged branches
git for-each-ref --format='%(refname)' refs/heads | while read branch; do
git rev-parse --quiet --verify "$branch" || continue # make sure it still exists
git symbolic-ref HEAD "$branch"
git branch -d $( git branch --merged | grep -v '^\*' )
done
git checkout master
# list possible merge commits to help create a grafts file
git log --pretty=one --all -E --grep='[mM]erge|\(orig r'
|