Last active
February 20, 2022 11:41
-
-
Save htgoebel/a88f2e7271c40ebf938b to your computer and use it in GitHub Desktop.
Playing with git read-tree
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
mkdir modulegraph | |
cd modulegraph/ | |
rm -rf * .hg* .git* | |
hg clone https://[email protected]/ronaldoussoren/modulegraph . | |
hg checkout modulegraph-0.12 | |
rm -rf .git* | |
git init . | |
git add .hg/hgrc | |
cat > .gitignore <<EOF | |
doc/build/ | |
modulegraph.egg-info | |
testsuite/testpkg-setuptools-namespace/src/nspkg.egg-info | |
__pycache__ | |
build/ | |
htmlcov | |
.coverage | |
.DS_Store | |
dist/ | |
*.swp | |
*.py[co] | |
*.dSYM | |
/.hg/ | |
/.hgignore | |
/.hgtags | |
EOF | |
git add .gitignore | |
git add * | |
git commit -m 'Initial commit' | |
# Now create the subtree-branch | |
head=$(git cat-file -p HEAD | grep tree | awk '{print $2}' ) | |
echo $head | |
tree=$(git cat-file -p $head | grep -P '\smodulegraph$' | awk '{print $3}') | |
echo $tree | |
git checkout -b subtree && rm -rf * .hg* | |
git checkout subtree | |
git read-tree $tree | |
#git add .gitignore | |
git commit -m 'Bringing subtree into new branch' | |
git checkout -f subtree | |
# Now test if we can update the vendor branch | |
git checkout -f master | |
rm -rf .hg * .hgtags .hgignore | |
git checkout .hg/hgrc | |
hg pull | |
hg checkout modulegraph-0.12.1 | |
git add --all | |
git commit -m 'Updating to version modulegraph-0.12.1' | |
## Okay, now we have modulegraph-0.12.1 in `master` | |
git checkout -f master | |
head=$(git cat-file -p HEAD | grep tree | awk '{print $2}' ) | |
echo $head | |
tree=$(git cat-file -p $head | grep -P '\smodulegraph$' | awk '{print $3}') | |
echo $tree | |
git checkout subtree | |
git read-tree $tree | |
#git add .gitignore | |
git commit -m 'Bringing subtree into new branch' | |
git checkout -f subtree |
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
mkdir modulegraph-vendor our-repo | |
vendor=$(readlink -f $PWD/modulegraph-vendor) | |
ours=$(readlink -f $PWD/our-repo) | |
cd $ours | |
git clone ~/devel/pyinstaller . | |
# Create a repo for the vendor code | |
cd $vendor | |
rm -rf * .hg* .git* | |
hg clone https://[email protected]/ronaldoussoren/modulegraph . | |
hg checkout modulegraph-0.12 | |
rm -rf .git* | |
git init . | |
git add .hg/hgrc | |
git add * | |
git commit -m 'Initial commit - modulegraph-0.12' | |
# Now create the subtree-branch | |
### I did not manage to make this work as I want! | |
cd $ours | |
git remote add vendor/modulgraph $vendor | |
git fetch vendor/modulgraph | |
git checkout -b vendor/modulgraph vendor/modulgraph/master | |
git diff-tree -p --relative=modulegraph/ python3:PyInstaller/lib vendor/modulgraph: | git apply --directory=PyInstaller/lib/modulegraph/ | |
git checkout -f python3 | |
cd PyInstaller/lib/modulegraph/ | |
git read-tree --prefix=PyInstaller/lib/modulegraph/ -u | |
git checkout --orphan vendor/modulgraph | |
git checkout vendor/modulgraph | |
git read-tree $tree | |
#git add .gitignore | |
git commit -m 'Bringing subtree into new branch' | |
git checkout -f subtree | |
# Now update the vendor repo | |
cd $vendor | |
git checkout -f master | |
hg pull | |
hg checkout modulegraph-0.12.1 | |
git add --all | |
git commit -m 'Updating to version modulegraph-0.12.1' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment