Skip to content

Instantly share code, notes, and snippets.

@pfalcon
Last active August 7, 2017 21:55
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pfalcon/6690030 to your computer and use it in GitHub Desktop.
A script to merge original mongoose commit history into civetweb repo.
#!/bin/sh
set -xe
# Anti-GPL paranoid delight: make it possible to swear on bible that
# no GPL commit ever entered civetweb repo
function prepare_mongoose_mit () {
git clone https://github.com/cesanta/mongoose
cd mongoose
# Civetweb started from this rev. There're couple more MIT-licensed
# commits in upstream repo
git reset --hard a0b43ae8e0a09d8ac3f7932de19f66b2677dafd2
# GPL commits, burn in fire of gc!
git gc
# Fire not enough, drown it
cd ..
git clone mongoose mongoose-mit
}
prepare_mongoose_mit
git clone https://github.com/sunsetbrew/civetweb
# 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
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