Last active
June 30, 2017 13:21
-
-
Save ermshiperete/c6301951b84d98c95f06b3b06d3884d1 to your computer and use it in GitHub Desktop.
Tools for fixing automated import from icu4c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create all branches | |
function CreateBranches() { | |
for b in $(git branch -r | grep $1); do | |
if [[ $b == *@* ]]; then | |
echo "Skipping $b" | |
continue | |
fi | |
sb=${b#$1/} | |
if [ "$sb" == "HEAD" -o "$sb" == "->" ]; then | |
continue | |
fi | |
echo "Create branch $sb" | |
git reset --hard -q | |
git clean -dxf -q | |
git checkout -q -b $sb $b | |
done | |
} | |
CreateBranches svn | |
#CreateBranches origin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sb=trunk | |
echo "********** Processing $sb" | |
rm .git/info/grafts | |
svnsha=$(git rev-list --max-parents=0 svn/$sb) | |
originsha=$(git show-ref origin/$sb | cut -f 1 -d ' ') | |
echo "$svnsha $originsha" >> .git/info/grafts | |
for b in $(git branch -r | grep svn); do | |
if [[ $b == *@* ]]; then | |
echo "Skipping $b" | |
continue | |
fi | |
sb=${b#svn/} | |
if [ "$sb" == "HEAD" -o "$sb" == "->" -o "$sb" == "trunk" ]; then | |
continue | |
fi | |
if ! git branch -r | grep -q origin/$sb ; then | |
echo "No branch $sb on origin; skipping" | |
continue | |
fi | |
echo "********** Processing $sb" | |
svnhas=$(git rev-list --max-parents=0 svn/$sb) | |
if [ $(echo $svnhas | wc -w) -gt 1 ]; then | |
# if we get more than 1 parent then a merge happened and we're | |
# probably the tags/latest branch. All parents are on more than one | |
# branch except one - that is the one we have to connect to the | |
# corresponding branch on origin. | |
# If we don't do this git will pick one of the parents | |
for commit in $svnhas; do | |
if [ $(git branch -r --contains $commit | wc -l) -gt 1 ]; then | |
continue | |
fi | |
originsha=$(git show-ref origin/$sb | cut -f 1 -d ' ') | |
echo "$commit $originsha" >> .git/info/grafts | |
done | |
else | |
originsha=$(git show-ref origin/$sb | cut -f 1 -d ' ') | |
echo "$svnhas $originsha" >> .git/info/grafts | |
fi | |
done | |
git filter-branch --tag-name-filter cat -- --all | |
rm .git/info/grafts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment