Skip to content

Instantly share code, notes, and snippets.

Last active December 24, 2015 03:19
Show Gist options
  • Save pfalcon/6736632 to your computer and use it in GitHub Desktop.
Save pfalcon/6736632 to your computer and use it in GitHub Desktop.
Testcase to reproduce error when rebasing a commit w/o textual changes, with chmod changes only
set -xe
function prepare_mongoose_mit () {
git clone
cd mongoose
# Civetweb started from this rev. There're couple more MIT-licensed
# commits in upstream repo
git reset --hard a0b43ae8e0a09d8ac3f7932de19f66b2677dafd2
git gc
cd ..
git clone mongoose mongoose-mit
git clone
# Leave original as is for comparison, make all ops on a separaet clone
rm -rf civetweb-merged
git clone civetweb civetweb-merged
cd civetweb-merged
git remote add upstream file://$PWD/../mongoose-mit
git fetch upstream
git checkout -b upstream-master upstream/master
git checkout master
# Once during rebase process, we get "all conflicts fixed: run "git rebase --continue""
# and "Could not pick 5831bf1affad12bfa3146c37b8b622ba4e584ca3". That commit is chmod
# of files, and rebase stumblng on it is of course a bug (few years ago such stumbles
# happen way often ;-) ).
# So, expected to exit with error
set +e
# Revision range here is [exclusive inclusive], e61d4efbe4d34d64e6be50ad5009045e4ff06764
# is the first rev in civet (initial import), so what we saying is take all commits
# from 2ns to last (HEAD) and transplant onto of upstream-master
git rebase --preserve-merges --onto upstream-master e61d4efbe4d34d64e6be50ad5009045e4ff06764 HEAD
set -e
git rebase --continue
# Result of a rebase above is a detached head, make it into a branch
git checkout -b merged
# Validate results
cd ..
# Invariant 1: contents of original and merged repos match
diff -x .git -urN civetweb civetweb-merged
# Invariant 2: tags still points to the revisions with same ids
(cd civetweb; git show-ref --tags >../civetweb.tags)
# Merged repo will also contain original mongoose tags
(cd civetweb-merged; git show-ref --tags | grep v1 >../civetweb-merged.tags)
diff -u civetweb.tags civetweb-merged.tags
set +x
echo "Repository merged and validated. Rename merged branch to master and push --force it"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment