Linuxbrew / legacy-linuxbrew

:skull: This repository is defunct, because it has been split into https://github.com/Linuxbrew/brew and https://github.com/Linuxbrew/homebrew-core
http://linuxbrew.sh
Other
2.23k stars 296 forks source link

Core/Formula separation #1033

Closed xu-cheng closed 8 years ago

xu-cheng commented 8 years ago

@sjackman

Just remind that we have shipped core/formula separation on Homebrew. Here is a TODO list for you to perform core/formula separation. NOTE: THE ORDER MATTERS

git filter-branch -f --prune-empty \
  --index-filter \
  'git rm --cached --ignore-unmatch -r -q -- Library/Formula Library/Aliases ;' \
  -- --all
sjackman commented 8 years ago

Thanks for the heads up and instructions, Xu.

sjackman commented 8 years ago

@Linuxbrew/core The upstream Homebrew repository has been split into brew, the package manager, and Homebrew-core, the formulas. Linuxbrew will adopt this split as well some time next week. If you have any open pull requests that you'd like to commit before the split, now's the time to do it. =)

sjackman commented 8 years ago

See Homebrew/legacy-homebrew#49752 and Homebrew/brew#1

xu-cheng commented 8 years ago

The two issues in your last comment are outdated. I suggest you reference to https://github.com/Homebrew/legacy-homebrew/issues/50650 for comprehensive list.

sjackman commented 8 years ago

Create a new Linuxbrew/brew repo. You could either fork Homebrew/brew then apply the diff between Homebrew/brew and Linuxbrew/linuxbrew. OR you could use following script then apply the missing change.

I'd rather not lose the history, so that git blame is still useful, so I'll use your script.

sjackman commented 8 years ago

Update Linuxbrew/homebrew-core repo to sync with Linuxbrew/linuxbrew and Homebrew/homebrew-core.

By this you mean bring Linuxbrew/homebrew-core up to date by merging the changes from Linuxbrew/linuxbrew and Homebrew/homebrew-core into Linuxbrew/homebrew-core?

xu-cheng commented 8 years ago

By this you mean bring Linuxbrew/homebrew-core up to date by merging the changes from Linuxbrew/linuxbrew and Homebrew/homebrew-core into Linuxbrew/homebrew-core?

Yes, you should make Linuxbrew/homebrew-core sync with Linuxbrew/linuxbrew then with Homebrew/homebrew-core.

sjackman commented 8 years ago

Update Linuxbrew to the sync with Homebrew/homebrew with https://github.com/Homebrew/legacy-homebrew/blob/master/Library/Homebrew/cmd/update.sh#L9-L15 point to proper url. This need to be done in the last step.

And by this you mean merge Homebrew/legacy-homebrew into Linuxbrew/linuxbrew.

Last step is to rename Linuxbrew/linuxbrew to Linuxbrew/legacy-linuxbrew.

xu-cheng commented 8 years ago

And by this you mean merge Homebrew/legacy-homebrew into Linuxbrew/linuxbrew.

Yep.

Last step is to rename Linuxbrew/linuxbrew to Linuxbrew/legacy-linuxbrew.

This is optional step.

Also, you can reach me on Slack for more specific questions.

sjackman commented 8 years ago

Thanks, Xu. I appreciate your help!

sjackman commented 8 years ago

Linuxbrew/linuxbrew:master is currently behind Homebrew/legacy-homebrew:master by 32 commits:

a7058e0 readme: clarify what's not in homebrew/brew [Alex Dunn]
7d148dc update: use --replace-all to set remote.origin.fetch [Xu Cheng]
6146a1c README: note migrations. [Mike McQuaid]
130bc02 Update/split documentation. [Mike McQuaid]
d32d78d various: add remote migration hack [Xu Cheng]
5f53fc3 update: migrate to new remote [Xu Cheng]
235d819 test-bot: exclude Taps dir from root cleanup [Andrew Janke]
1e92c7f test-bot: have --cleanup clean core repo as well as tested tap [Andrew J
48e5079 test-bot: fix path in cleanup_before [Xu Cheng]
ef6cbe9 pull: fix --legacy when pulling bottle from new repo [Xu Cheng]
e13ff62 Revert "test-bot: clean up on Jenkins before building PR" [Martin Afanas
51e4e64 test-bot: clean up on Jenkins before building PR [Martin Afanasjew]
ef70efa diagnostic: improve check for 'install_name_tool' [Mike McQuaid]
60f8861 test-bot: ensure tap is full clone [Xu Cheng]
73bece8 test-bot: fix CI upload for core tap [Xu Cheng]
fc80d72 pull: auto fix legacy closes message [Xu Cheng]
c38cbf5 pull: fallback to old BrewTestBot git repo when necessary [Xu Cheng]
6ed1425 test-bot: handle legacy formulae PR from Homebrew/homebrew [Xu Cheng]
71cba60 doc: update for core/formula separation [Xu Cheng]
dc94fbc tap-(un)pin/untap: better error message [Xu Cheng]
68d6718 update-test: fix git fork bomb [Xu Cheng]
b3aadea pull: add --legacy flag [Xu Cheng]
edb7e9f bump Homebrew version to 0.9.8 [Xu Cheng]
1e33dcb git: check homebrew/core existence before installing brewed git [Xu Chen
33404b3 fix brew tests [Xu Cheng]
af81f99 --version/config: show core tap information [Xu Cheng]
7417397 audit/test-bot/pull: fix for core/formula separation [Xu Cheng]
1d13a03 descriptions: update for core/formula separation [Xu Cheng]
deac0d8 update-report: update for core/formula separation [Xu Cheng]
bf41e3c remove migrate_taps [Xu Cheng]
c831b1e various: Homebrew/core is the core tap [Xu Cheng]
f4a303a introduce `Homebrew/core` tap as new default core tap. [Xu Cheng]
sjackman commented 8 years ago

@xu-cheng Can all 32 commits be merged into Linuxbrew/linuxbrew at once (as the last step)?

sjackman commented 8 years ago

There's a bunch of conflicts to resolve, but I'll deal with that.

xu-cheng commented 8 years ago

Yes, you can. Just to remember to do this at the very last step.

sjackman commented 8 years ago

What does the git filter-branch script do? Is it rewriting history, or creating new commit(s)?

xu-cheng commented 8 years ago

It's rewriting the entire git history. So you should run it in a separate copy.

sjackman commented 8 years ago

If it's rewriting history, will it leave the repository in a state that Homebrew/brew can be merged into Linuxbrew/brew? I'm afraid that they'll have totally different commit histories after it's done. They may not share any common commit SHA1.

sjackman commented 8 years ago

Would a simple git rm Library/Formula Library/Aliases be possible?

sjackman commented 8 years ago

Perhaps the easiest way to find out is just to try it and see what happens. Run the script and then try merging Homebrew/brew into Linuxbrew/brew and see what happens.

sjackman commented 8 years ago

If it rewrites history on the homebrew/master branch exactly as it did when you ran it, and produces identical results, then maybe the git commit SHA1 will match up. Fingers crossed.

xu-cheng commented 8 years ago

If it's rewriting history, will it leave the repository in a state that Homebrew/brew can be merged into Linuxbrew/brew? I'm afraid that they'll have totally different commit histories after it's done.

I dunno. So I would suggest to fork then apply the changes. Or you could use this to find all the different commit http://stackoverflow.com/questions/7566416/different-commits-between-two-branches

Would a simple git rm Library/Formula Library/Aliases be possible?

But it will introduce a large git history.

then maybe the git commit SHA1 will match up. Fingers crossed.

I don't think that will happen.

sjackman commented 8 years ago

What script did you use to create Linuxbrew/homebrew-core?

sjackman commented 8 years ago

Homebrew/homebrew-core and Linuxbrew/linuxbrew-core agree (have the same SHA1) for the first 62 commits, then the commit Remove MacPorts and Fink from the build environment has SHA1 of https://github.com/Homebrew/homebrew-core/commit/ead43565c24ba5139ee8b81095d84e2f54f446b4 in Homebrew/homebrew-core, but https://github.com/Linuxbrew/homebrew-core/commit/a6c6c6342f52af34d24bcda0a27fdbfebcd54683 in Linuxbrew/homebrew-core because the commit message was rewritten to change Closes #13 to Closes Homebrew/homebrew#13.

--- linuxbrew
+++ homebrew
@@ -1,10 +1,10 @@
-commit a6c6c6342f52af34d24bcda0a27fdbfebcd54683
+commit ead43565c24ba5139ee8b81095d84e2f54f446b4
 Author: Max Howell <max@methylblue.com>
 Date:   Tue Aug 11 14:46:04 2009 +0100

     Remove MacPorts and Fink from the build environment

-    Closes #13
+    Closes Homebrew/homebrew#13

 diff --git a/Formula/apr.rb b/Formula/apr.rb
 new file mode 100644

Do you have the exact script that was used to rewrite the history of Homebrew/brew and Homebrew/homebrew-core? I'll need to reproduce it exactly to end up with a repository that is compatible with Homebrew and can be merged.

sjackman commented 8 years ago

I'm trying this out:

git filter-branch -f --prune-empty \
  --index-filter 'git rm --cached --ignore-unmatch -r -q -- Library/Formula Library/Aliases ;' \
  --msg-filter 'sed -Ee "s~\B#[0-9]+\b~Homebrew/homebrew&~g"' \
  -- --all

It needs to be fixed up to change #123 to either Homebrew/homebrew#123 or Linuxbrew/linuxbrew#123.

sjackman commented 8 years ago

In https://github.com/Homebrew/brew/commit/a13ff43886f5255694ead2789a65bda3b97dd6b9, the log message Fixes #10341. was not rewritten to Fixes Homebrew/homebrew#10341. The spaces between s and # is a non-breaking space, Unicode point U+00A0 NO-BREAK SPACE.

What regex was used to match issue numbers?

sjackman commented 8 years ago

Now trying…

git filter-branch -f --prune-empty \
  --index-filter 'git rm --cached --ignore-unmatch -r -q -- Library/Formula Library/Aliases ;' \
  --msg-filter 'sed -Ee "s~ (#[0-9]+)~ Homebrew/homebrew\1~g"' \
  -- --all
sjackman commented 8 years ago

The commit time stamp of the commit with the log message tap: add methods to get git related information changed from 2016-03-05T17:38:13+00:00 to 2016-03-06T05:51:06+00:00.

--- legacy-homebrew 2016-04-15 10:47:06.000000000 -0700
+++ brew    2016-04-15 10:47:23.000000000 -0700
@@ -1,15 +1,15 @@
-commit 73e5d38c3592115a74c7004b475fc26cfa974f2c
+commit 9f96e41b40f52313fbc7832df631827f5e3bcacb
 Author:     Xu Cheng <xucheng@me.com>
 AuthorDate: 2016-03-05T12:03:43+00:00
 Commit:     Xu Cheng <xucheng@me.com>
-CommitDate: 2016-03-05T17:38:13+00:00
+CommitDate: 2016-03-06T05:51:06+00:00

     tap: add methods to get git related information

     These methods will be used in `brew --version`, `brew config`
     and `brew doctor` after core/formula separation.

-    Closes #49796.
+    Closes Homebrew/homebrew#49796.

     Signed-off-by: Xu Cheng <xucheng@me.com>
xu-cheng commented 8 years ago

FYI, this is the script I used to create both repos. https://gist.github.com/xu-cheng/a7f788d28ea27c2722ff

I didn't do the git message rewriting. Because I'm not sure whether #number should be rewritten to Homebrew/homebrew#number or Linuxbrew/linuxbrew#number as there will be some overlap.

The commit time stamp of the commit with the log message.

This is because during the time between I created Homebrew/brew to the time we started to use it, all the commits are manually synced from Homebrew/homebrew using git format-patch and git am.

xu-cheng commented 8 years ago

Also, I don't think you will get same SHA1 eventually. Instead, I suggest you do git rebase --onto to force to sync between Homebrew and Linuxbrew.

sjackman commented 8 years ago

So far I am getting identical SHA1, as long as the commit message and time stamps match identically (and of course the file content). I'm not sure that git-rebase will work through the merge commits. If I tried to rebase onto homebrew/master, older Linuxbrew commits that no longer apply to the current Homebrew code will conflict. I'd have to deal with possibly dozens to hundreds of merge conflicts, unless I first squashed, which would lose a lot of history.

sjackman commented 8 years ago

The committer author and date of 103 revisions changed from legacy-homebrew to brew starting with the commit mentioned above, tap: add methods to get git related information on 2016-03-05T12:03:43+00:00.

I've matched up the commits between legacy-homebrew and brew based on their author date, which didn't change, and subject, which wouldn't change as long as there's no issue #123 mentioned in the subject (thankfully, there are none), and created a mapping from the old SHA1 in legacy-homebrew to the new commit date for that same commit in brew for use with git filter-branch --env-filter.

The author's time zone is part of the git commit that is digested by SHA1. Same UTC time but changing the time zone changes the commit SHA1.

See http://rpubs.com/sjackman/compare-committer-date

sjackman commented 8 years ago

Here's the script that I'm testing now. Wish me luck.

git filter-branch -f --msg-filter 'sed -Ee "s~ (#[0-9]+)~ Linuxbrew/linuxbrew\1~g"' -- 7814c5b9393a7dabc6b78e51bc21a7d3a6999dd2...master
git filter-branch -f --prune-empty \
  --index-filter 'git rm --cached --ignore-unmatch -r -q -- Library/Formula Library/Aliases ;' \
  --msg-filter 'sed -Ee "s~ (#[0-9]+)~ Homebrew/homebrew\1~g"' \
  --env-filter \
'case $GIT_COMMIT in'"
53c50891d96c85a3f5ce6fc2acc9e1c6d7905d65) GIT_COMMITTER_DATE='1459856087 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
235d819edf77fb3fe08714c3cf3489d5de08fc96) GIT_COMMITTER_DATE='1459665072 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
1e92c7f4316a2e37d8ec03b73c8e4e3d2b24a18f) GIT_COMMITTER_DATE='1459665072 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
48e5079dbddc994f65ce4ddc215479ba46af475e) GIT_COMMITTER_DATE='1459665072 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
ef6cbe93363d6e1e579dee56d7e94795f745e25d) GIT_COMMITTER_DATE='1459656947 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
e13ff6294a0bbc28fc98d6f797b1b56ce93ecd67) GIT_COMMITTER_DATE='1459656947 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
51e4e6490bda0d981afd1787a6392ab588b0601c) GIT_COMMITTER_DATE='1459656947 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
ef70efa204c929b01ba0e7a4da843c70ed455313) GIT_COMMITTER_DATE='1459656947 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
60f8861ce3dc964f08305237b667f3959de20d45) GIT_COMMITTER_DATE='1459614849 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
73bece8744faa316cdde3160a170f4241303032c) GIT_COMMITTER_DATE='1459613441 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
fc80d72079b770a516d234f4e0eb8ca50fe063db) GIT_COMMITTER_DATE='1459613441 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
c38cbf514d1ead438b235f09a5607faa580b702b) GIT_COMMITTER_DATE='1459612898 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
6ed1425b9fb8273ac9b367f08e41ca53afae8b97) GIT_COMMITTER_DATE='1459612898 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
71cba6064f73c3e9ea46d10879f1b503bea86586) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
dc94fbc68a15af37de0691895e7f6247c94ec593) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
68d6718e53e2d1f155d0261aafb3a3585c425d83) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
b3aadea002b5fd6847d710929423f13d5af5b0bd) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
edb7e9f4b539d758ab402f14c48a3effa9316e05) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
1e33dcb974207fec295516124ab0a2c1a3fa9146) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
33404b32ef9e8ebbbbcdcecd7ea77e0d2b3a926d) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
af81f99442ff2616ac10b6e4ea5750e7f953f3d1) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
74173972ffbb21d314b6b0f4b85af4c2b71f816f) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
1d13a03cfdb50ec2b014bf82cb5a612e30c0bcbe) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
deac0d8cca8484b82492cdc68da3feb2a51b795b) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
bf41e3c44d61c60abc3f07016dc6f1b9175828dc) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
c831b1efe9e302bed914dcf1119b706b9137ee93) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
f4a303aa9f194370eb52cda1bd39e97b771449fb) GIT_COMMITTER_DATE='1459605096 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
a1a71b8f46ee364a3c096197a9a415c85c9d3dd7) GIT_COMMITTER_DATE='1459499414 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
3d622f85544cc4a72a66989c2c85849d8b054295) GIT_COMMITTER_DATE='1459415422 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
a9602a5238a91e1f3ad6696c2ee1f02ab7dc6a9d) GIT_COMMITTER_DATE='1459415422 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
798ad40e80647a9add30a6714060a759df644192) GIT_COMMITTER_DATE='1459406941 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
ee6aa7a78edb91f168b74b3944d64cdeed040cb1) GIT_COMMITTER_DATE='1459401410 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
aa60ce7571b98c09c479b58b3c9cfc9edd988fee) GIT_COMMITTER_DATE='1459401410 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
be679f91eb6c67c7574485782e4f0cfa456d8ed9) GIT_COMMITTER_DATE='1459401410 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
89990349813d9c93beb8ca8c74f78798a1bea01e) GIT_COMMITTER_DATE='1459239577 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
64caad7c79208807d595d5189c45e92067b3c8ef) GIT_COMMITTER_DATE='1459160567 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
04a99f1eedd993c053053689876de54e169f0992) GIT_COMMITTER_DATE='1459160567 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
f1068094455f9b7072cd1e6a3bf1ebec11ea1a4b) GIT_COMMITTER_DATE='1459160567 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
0081b8c1060f04422b2134f3975113b6f8f1f7a0) GIT_COMMITTER_DATE='1458975010 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
b244376ca6d01fcde6c9d181c8ffd11cf8f11152) GIT_COMMITTER_DATE='1458975010 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
32aeb46b6c2d4c95c9cfd4c5b85f62be2553d556) GIT_COMMITTER_DATE='1458975010 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
6207527aabffe39a65f41393849b9c3c2ee04425) GIT_COMMITTER_DATE='1458975010 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
cddee3c5dfc5721a804787a4760ce0c3251eaf66) GIT_COMMITTER_DATE='1458975010 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
d6e5ecff5b89ef6b0b079763b60191be5010986c) GIT_COMMITTER_DATE='1458975010 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
be7f2b5b0e72cf6389e8ad76a0cb7128058dc248) GIT_COMMITTER_DATE='1458802333 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
c5be64cfa1b8c6dfb5c9df08b95c27a8f445ac99) GIT_COMMITTER_DATE='1458802333 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
f38a816f03bf964173f5aadcc637b66062d7e9ab) GIT_COMMITTER_DATE='1458716488 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
fe0c3127d088921a7adaaa9429bb110ff48fac3f) GIT_COMMITTER_DATE='1458711676 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
2fd4075442849672906aab1d1b12d214a9b64f9c) GIT_COMMITTER_DATE='1458647056 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
a1824f82b271b14b93f1f401a1ceb47bee9414a6) GIT_COMMITTER_DATE='1458644119 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
eaf0b54999fa52dad729a9793d27963e14713e69) GIT_COMMITTER_DATE='1458644119 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
f715e0e48e78a4338a8af7cf5e94715a02f13526) GIT_COMMITTER_DATE='1458644119 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
f8a8e876c5b6f7c287e147620ea7a0f4209bbea5) GIT_COMMITTER_DATE='1458558458 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
30e7dc8eb12723a754661a5b9e0f26ec2d8c5cfb) GIT_COMMITTER_DATE='1458558458 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
a3186130dd7ac3075987b5c9bcbad74de767a64a) GIT_COMMITTER_DATE='1458558458 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
cc0fd25ff1caba9520660a2b02179213f13fc76a) GIT_COMMITTER_DATE='1458558458 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
51d8d735a106f4f70769cdfd19fb21f64dee8373) GIT_COMMITTER_DATE='1458456958 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
e95f61b55a010eac056078ca47878f4e997bc2c8) GIT_COMMITTER_DATE='1458456958 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
ac2fe466e03dc8ecbcbb14eb439644bdb68addb9) GIT_COMMITTER_DATE='1458456958 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
41998df03cac9d421716ecb573d66c60d6a805bc) GIT_COMMITTER_DATE='1458456958 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
291583de2d7fef89a4b5135153630de0f1828065) GIT_COMMITTER_DATE='1458452898 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
48cfc1d2ed3041998eca2387003c9960df8f75cc) GIT_COMMITTER_DATE='1458386090 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
e0f5b710002a4e7bef647a75a2e13b8b64fdb6ca) GIT_COMMITTER_DATE='1458386090 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
c6183aaea9304cc3f0f38583d890004830cc6fe8) GIT_COMMITTER_DATE='1458386090 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
8c7f3d859e8f715b6c63e4fe75e7a636aee4167f) GIT_COMMITTER_DATE='1458386090 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
e5fa93d36e6505419cd9a3f6d7e15bfe3cdb93a2) GIT_COMMITTER_DATE='1458386090 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
5e6cea284d64b43ac4959bc8c1409ddd2442e136) GIT_COMMITTER_DATE='1458386090 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
d1793bf0afb46fcf5d7cf945fc1d6b173d523f2c) GIT_COMMITTER_DATE='1458386090 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
5cebfce08f50977f1861c5c76cf1eb7d25463837) GIT_COMMITTER_DATE='1458386090 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
e1c8965ca9ec7d3f23c1d01c5655e2eb20c5fd0b) GIT_COMMITTER_DATE='1458386090 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
5a850cf3a831c2a7e0201561414d7736f7d0c34c) GIT_COMMITTER_DATE='1457959293 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
7032591bd44a8f50aaa55574ac97cd5cb7261460) GIT_COMMITTER_DATE='1457958815 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
946c6deb4b5168ad2ec15e62aa6e81181e9e246c) GIT_COMMITTER_DATE='1457956695 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
0b38f9b286bc61e2b2d2232f80ea8ebc5909fb07) GIT_COMMITTER_DATE='1457955555 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
0d2de365e2c9f1be5a623c2602270f225ca07b5f) GIT_COMMITTER_DATE='1457955555 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
4b30df263ea85c61ec585b9859a3ba7b9b17e91f) GIT_COMMITTER_DATE='1457850725 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
2d5e5133588ac4face3b3e486b9448c52684ffa2) GIT_COMMITTER_DATE='1457850725 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
cfef282c5011e39b75329d01b45cfd53f6a10749) GIT_COMMITTER_DATE='1457850725 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
f0139e7164f95492cb9ea8007bef26525b83a16f) GIT_COMMITTER_DATE='1457850725 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
5a1c57ab88eee6629922c8f4ebc1e1c3b67b0c45) GIT_COMMITTER_DATE='1457850725 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
34b4dcf11de0ee024e2b9cd166e17d1f671ef57a) GIT_COMMITTER_DATE='1457850725 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
99e15f4192b9d1b402ce36b3eec176df2839c98b) GIT_COMMITTER_DATE='1457674374 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
397c202fb0e5a1bb4d03ceb61f54645f09d4aae6) GIT_COMMITTER_DATE='1457674374 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
626169d742ea572963e0f7b73762a555e846adbc) GIT_COMMITTER_DATE='1457606743 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
1747420b2f65d5f365b989b38880daf8c7a0f318) GIT_COMMITTER_DATE='1457524046 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
0aa300507881f52f31203424470b3ebfc3c87faf) GIT_COMMITTER_DATE='1457523341 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
d7732afe0581fe63cd2f8791dc4692ef271c5773) GIT_COMMITTER_DATE='1457516326 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
9e9dfb6a8dfc5440dac596077bbe7498cf9ded4b) GIT_COMMITTER_DATE='1457510422 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
b5f35c8a3e1e200b4c2f18a82084324980b2c816) GIT_COMMITTER_DATE='1457445309 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
2a1365dcf09148db64200ebbcd0e7089895aae37) GIT_COMMITTER_DATE='1457441531 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
fc3404b2fc7b4c9fda8a67db7193f9d6f25dc10c) GIT_COMMITTER_DATE='1457440579 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
0525c9eeea27eff1a6de05e7a01ec268ae07437b) GIT_COMMITTER_DATE='1457440579 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
943ea8c3708ec9a56de9f9234702c863e30ca690) GIT_COMMITTER_DATE='1457440579 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
e931b19643a6da8326fd454c46b45be1237ebe70) GIT_COMMITTER_DATE='1457416049 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
b6c814e2c8aa6fb6180bcc81d7e250d61f458ec4) GIT_COMMITTER_DATE='1457416049 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
9cc7a2b7c58838f5d2c9a058b7dbae166e4c97bb) GIT_COMMITTER_DATE='1457352035 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
7970035e5d8bdaf201e44b0fa84a047f9f67ab22) GIT_COMMITTER_DATE='1457351026 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
d4cb0763050f18b3803f2fba01558041bc5690c7) GIT_COMMITTER_DATE='1457351026 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
51b94f3b278543dd482dabd5926148fcfb2e6522) GIT_COMMITTER_DATE='1457351026 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
142c94ce0d453e3209f5502238b354658de4e039) GIT_COMMITTER_DATE='1457351026 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
82c434aa066d2e4a62c0c2c799c8caf4b6e21bca) GIT_COMMITTER_DATE='1457351026 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
fbcd95b1634f8cfbdc04c90701515e81368e6501) GIT_COMMITTER_DATE='1457243466 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
73e5d38c3592115a74c7004b475fc26cfa974f2c) GIT_COMMITTER_DATE='1457243466 +0800' GIT_COMMITTER_NAME='Xu Cheng' GIT_COMMITTER_EMAIL='xucheng@me.com';;
esac
export GIT_COMMITTER_DATE GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
" \
   -- --all
sjackman commented 8 years ago

This commit very nearly works. Up until now, the graph topology of the commits have remained unchanged. An empty merge commit was removed with the mesage Merge remote-tracking branch 'origin/master' which is the parent commit of Avoid pathological trailing slash in legacy-homebrew, but in brew this merge commit does not exist, and the parent commit is Formula Cookbook: /environmental/environment/.

I was hoping that git filter-branch --prune-empty would remove empty merge commits, but it explicitly does not:

this switch only applies for commits that have one and only one parent

Googling for git filter-branch prune empty merge commits shows other people trying to accomplish this same task. This script from SO is working nicely to remove empty merge commits using git filter-branch --parent-filter to remove redundant parents.

sjackman commented 8 years ago

Unfortunately there's an older empty merge commit that was not removed from brew, 001b8de Merge branch 'qt5', so it's important not to remove empty merge commits from the entire git commit history, but only commits after 001b8de Merge branch 'qt5' 2014-01-11 15:58:34 +0000

sjackman commented 8 years ago

This script removes empty merge commits after and not including 001b8de Merge branch 'qt5' 2014-01-11 15:58:34 +0000.

git filter-branch -f --prune-empty --parent-filter '
ruby -e '"'"'
old_parents = gets.chomp.gsub("-p ", " ")
new_parents = if old_parents.empty? then
  []
else
  `git show-branch --independent #{old_parents}`.split
end
puts new_parents.map{|p| "-p " + p}.join(" ")
'"'" \
-- 001b8de679e776516ae266699e40d403945137d2..master
sjackman commented 8 years ago

It works! The above two scripts can take the existing Linuxbrew/linuxbrew repository and rewrite its history so that every commit in Homebrew/brew has a corresponding commit with an identical SHA1 in the newly created Linuxbrew/brew repository. To accomplish this feat, the exact same transformations that were applied to Homebrew/homebrew to create Homebrew/brew must be repeated exactly. Those transformations include:

  1. tree-filter: Remove the directories Library/Formula and Library/Aliases
  2. msg-filter: Change issue references like #123 to Homebrew/homebrew#123
  3. env-filter: Change the committer author and committer date of 103 revisions listed above.
  4. parent-filter: Remove empty merge commits after and not including 001b8de Merge branch 'qt5' 2014-01-11 15:58:34 +0000. but do not remove empty merge commits before that commit

The resulting repository is at https://github.com/Linuxbrew/brew

sjackman commented 8 years ago

I'm going to tackle Homebrew/homebrew-core now.

sjackman commented 8 years ago

Here's the scripts with some explanation: https://github.com/sjackman/rewrite-git-history It has the scripts for brew. I'll add the scripts for homebrew-core probably later tonight if it goes well.