summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-10-19 17:51:09 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-10-19 17:51:09 +0900
commit7b564040ab2079a5d358c4cdd649f432c12a8302 (patch)
tree0db3cc755d3b931ef9e2adb8c5456942fde3287d
parentd2ffb5d7af48c06f547c82b319dbd63f362380cb (diff)
downloadruby-openssl-history-TODO.tar.gz
uipdTODO
-rwxr-xr-xextract-ruby-svn56
-rw-r--r--memo.md28
2 files changed, 83 insertions, 1 deletions
diff --git a/extract-ruby-svn b/extract-ruby-svn
new file mode 100755
index 0000000..63bedb9
--- /dev/null
+++ b/extract-ruby-svn
@@ -0,0 +1,56 @@
+#!/bin/sh
+set -e
+
+sha1_to_rev() { git show -s --format=format:%B $1 | tail -n1 | grep -Po '(?<=@)[0-9]+'; }
+rev_to_sha1() { git log --format=format:%H -n1 --grep '^git-svn-id: .*@'$2' ' $1; }
+
+BRANCH_EXTRACT=trunk-origin
+[ "$(git branch --list $BRANCH_EXTRACT)" ] ||
+ git branch $BRANCH_EXTRACT ruby-src/trunk
+
+[ ! -f trunk-work/.git ] &&
+ git worktree add trunk-work $BRANCH_EXTRACT
+
+cd trunk-work
+git checkout $BRANCH_EXTRACT
+
+# HEAD==ruby-src/trunk: first run; rewrite everything
+if [ $(git rev-parse HEAD) = $(git rev-parse ruby-src/trunk) ]; then
+ filter_range=
+else
+ old_head=$(git rev-parse HEAD)
+ echo "Updating '$BRANCH_EXTRACT'... HEAD was $old_head."
+ graftpoint="$(rev_to_sha1 ruby-src/trunk $(sha1_to_rev $old_head)) $old_head"
+ grep "^$graftpoint$" $(git rev-parse --git-common-dir)/info/grafts >/dev/null 2>&1 ||
+ echo "$graftpoint" >> $(git rev-parse --git-common-dir)/info/grafts
+ git reset -q --hard ruby-src/trunk
+ filter_range=$old_head..$BRANCH_EXTRACT
+fi
+
+echo "## Remove unrelated commits"
+git filter-branch -f --prune-empty --index-filter '
+ git rm --cached -qr --ignore-unmatch . &&
+ git reset -q $GIT_COMMIT -- ext/openssl test/openssl sample/openssl &&
+ git rm --cached -q --ignore-unmatch ext/openssl/depend ext/openssl/openssl.gemspec
+' -- $filter_range ||:
+
+echo "## Adjust path"
+git filter-branch -f --prune-empty --index-filter '
+ git ls-files --stage | \
+ sed "s:\ttest/openssl:\ttest:" | \
+ sed "s:\text/openssl/lib:\tlib:" | \
+ sed "s:\text/openssl/sample:\tsample/openssl:" | \
+ sed "s:\tsample/openssl:\tsample:" | \
+ GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info &&
+ mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"
+ :
+' -- $filter_range ||:
+
+echo "## Fix author/committer email"
+git filter-branch -f --env-filter '
+ export GIT_AUTHOR_EMAIL=${GIT_AUTHOR_EMAIL/b2dd03c8-39d4-4d8f-98ff-823fe69b080e/ruby-lang.org}
+ export GIT_COMMITTER_EMAIL=${GIT_COMMITTER_EMAIL/b2dd03c8-39d4-4d8f-98ff-823fe69b080e/ruby-lang.org}
+' -- $filter_range ||:
+
+[ "$graftpoint" ] &&
+ sed -ie "/^$graftpoint$/d" $(git rev-parse --git-common-dir)/info/grafts
diff --git a/memo.md b/memo.md
index 3f03536..3b5437c 100644
--- a/memo.md
+++ b/memo.md
@@ -13,7 +13,7 @@ name, address is taken from http://www.nongnu.org/rubypki/
start tag is removed, master and majkl branches are removed, origin is renamed to ossl1-origin, ossl2-origin respectively
- $ git branch master ossl2-origin
+ $ git branch ossl-combined ossl2-origin
graft merged point
@@ -36,3 +36,29 @@ cleanup history.Run for all refs
$ git filter-branch -f --prune-empty --index-filter '
git rm --cached -q --ignore-unmatch Makefile mkmf.log
' -- HEAD
+
+# Extracting from Ruby trunk tree
+
+set up remote; github mirror can be used but it takes much time for me
+
+ $ git remote add ruby-src -t trunk git://git.rhe.jp/ruby.git
+ $ git fetch ruby-src
+
+Run git filter-branch to filter out unrelated history. First run takes 20- mins
+Email address is not updated - "{committer} <{committer}@ruby-lang.org>" is used.
+
+ $ ./extract-ruby-svn
+
+# Combining these two
+
+ $ echo '9474b65b17132dd2c6b9d8b63c22d5e896926bbd af81e3e12742809d14867321ecb55349226f9663' > .git/info/grafts
+ $ git show --oneline 9474b65b17132dd2c6b9d8b63c22d5e896926bbd
+ 9474b65b1713 * ext/openssl: imported.
+ $ git show --oneline af81e3e12742809d14867321ecb55349226f9663
+ af81e3e12742 Remove not-used core
+ $ git branch master trunk-origin
+ $ git filter-branch master
+
+# When trunk is updated
+
+Run extract-ruby-svn and re-combine