{"thread":{"id":"26258","subject":"Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?","startedAt":"2011-01-11T10:41:01Z","lastAt":"2011-01-15T00:04:28Z","messageCount":18,"participants":["Алексей Шумкин","Martin Krüger","Andreas Ericsson","Jakub Narebski","Jonathan Nieder","Maaartin","Alexey Shumkin","Maaartin-1"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"159318","messageId":"746745466.20110111134101@mail.ru","threadId":"26258","inReplyTo":null,"subject":"Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?","fromName":"Алексей Шумкин","fromEmail":"zapped@mail.ru","sentAt":"2011-01-11T10:41:01Z","receivedAt":"2011-01-11T10:41:01Z","isPatch":false,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"Hi all!\n\n1.5 years ago I had sources of a project in a SVN repository (actually it does not\nmatter what SCM was used before). And I had two branches: v2.4 and v2.5.\nThey differed enough at that moment and (as usual for SVN branches)\nlaid in two different folders.\nThen I had known of Git and I decided to try to use this powerful DVCS.\nBut as I was a newbie I created two git-repositories: one per each\nbranch. So v2.4 has its own git-repo. v2.5 (and above) has another one.\n\nNow I'd like to merge them as v2.5 was a continuos branch from v2.4,\nbut without a rebasing (i.e. without a global changing of v2.5\nrepository, which already has another branches)\nIt must look like LAST commit of v2.4 should be a PARENT of FIRST commit of v2.5\n\nNow there's a question: Is it possible to do so (no rebasing!), and If\n\"yes\" then how to?\n"},{"id":"159320","messageId":"20110111114943.40890@gmx.net","threadId":"26258","inReplyTo":"746745466.20110111134101@mail.ru","subject":"Re: Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?","fromName":"Martin Krüger","fromEmail":"martin.krueger@gmx.com","sentAt":"2011-01-11T11:49:43Z","receivedAt":"2011-01-11T11:49:43Z","isPatch":false,"sender":{"key":"martin.krueger@gmx.com","avatar":null},"body":"> \n> Now I'd like to merge them as v2.5 was a continuos branch from v2.4,\n> but without a rebasing (i.e. without a global changing of v2.5\n> repository, which already has another branches)\n> It must look like LAST commit of v2.4 should be a PARENT of FIRST commit\n> of v2.5\n> \n> Now there's a question: Is it possible to do so (no rebasing!), and If\n> \"yes\" then how to?\n> \n>\nIt's possible with a little arts an crafts. \nYou have 2 friends:  git format-patch & git am .\nWith \"git format-patch\" you  will see what a branch really is:\na serie of patches.  With \"git am\"  you can apply these patches to a branch created on the correct point of the commit-history . E voila the branch is recreated in the repository.\n\nIn your case:\n\nOn the 2.5 repository master branch:\ngit format-patch  INITIAL_COMMITID\n\nOn the 2.4 repository master branch:\ngit branch 2.5\ngit checkout 2.4\ngit reset --hard  INITIAL_COMMITID \ncat *.patch | git am\n\nE voila you habe both branches in a single repository.\n\nNearly  same procedure for every  branch of the  2.5 repository\ngit checkout branchname \ngit format-patch master\n\nIn the 2.4(Contains now both branches.) respository:\ngit checkout 2.5\ngit branch branchname\ngit reset --hard CORRECT_BRANCHBASE\ncat *.patch | git am\n\nBest regards \n   martin\n\n\n\n \n"},{"id":"159324","messageId":"76067992.20110111153329@mail.ru","threadId":"26258","inReplyTo":"20110111114943.40890@gmx.net","subject":"Re[2]: Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?","fromName":"Алексей Шумкин","fromEmail":"zapped@mail.ru","sentAt":"2011-01-11T12:33:29Z","receivedAt":"2011-01-11T12:33:29Z","isPatch":false,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"Thank you for the answer, but it's not what I want ))\nApplying patches is the same as rebasing, I guess.\nBut I do not want to change v2.5-repo (let's call it so) that much.\nI'd like to know is there any method (low-level I suppose, as far as Git\nmanages tree-objects as files) to make v2.4 LAST commit to be the\nparent of v2.5 FIRST commit?\n\nMK> It's possible with a little arts an crafts.\nMK> You have 2 friends:  git format-patch & git am .\nMK> With \"git format-patch\" you  will see what a branch really is:\nMK> a serie of patches.  With \"git am\"  you can apply these patches\nMK> to a branch created on the correct point of the commit-history . E\nMK> voila the branch is recreated in the repository.\n\nMK> In your case:\n\nMK> On the 2.5 repository master branch:\nMK> git format-patch  INITIAL_COMMITID\n\nMK> On the 2.4 repository master branch:\nMK> git branch 2.5\nMK> git checkout 2.4\nMK> git reset --hard  INITIAL_COMMITID \nMK> cat *.patch | git am\n\nMK> E voila you habe both branches in a single repository.\n\nMK> Nearly  same procedure for every  branch of the  2.5 repository\nMK> git checkout branchname \nMK> git format-patch master\n\nMK> In the 2.4(Contains now both branches.) respository:\nMK> git checkout 2.5\nMK> git branch branchname\nMK> git reset --hard CORRECT_BRANCHBASE\nMK> cat *.patch | git am\n"},{"id":"159327","messageId":"4D2C500F.6070203@op5.se","threadId":"26258","inReplyTo":"76067992.20110111153329@mail.ru","subject":"Re: Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2011-01-11T12:41:51Z","receivedAt":"2011-01-11T12:41:51Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"On 01/11/2011 01:33 PM, Алексей Шумкин wrote:\n> Thank you for the answer, but it's not what I want ))\n> Applying patches is the same as rebasing, I guess.\n> But I do not want to change v2.5-repo (let's call it so) that much.\n> I'd like to know is there any method (low-level I suppose, as far as Git\n> manages tree-objects as files) to make v2.4 LAST commit to be the\n> parent of v2.5 FIRST commit?\n> \n\nYou want grafts. Check them up in the docs. Googling for \"git graft\"\nshould get you a good starting point.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n\nConsidering the successes of the wars on alcohol, poverty, drugs and\nterror, I think we should give some serious thought to declaring war\non peace.\n"},{"id":"159328","messageId":"20110111124712.40910@gmx.net","threadId":"26258","inReplyTo":"76067992.20110111153329@mail.ru","subject":"Re: Re[2]: Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?","fromName":"Martin Krüger","fromEmail":"martin.krueger@gmx.com","sentAt":"2011-01-11T12:47:12Z","receivedAt":"2011-01-11T12:47:12Z","isPatch":false,"sender":{"key":"martin.krueger@gmx.com","avatar":null},"body":"\n> Thank you for the answer, but it's not what I want ))\n> Applying patches is the same as rebasing, I guess.\n> But I do not want to change v2.5-repo (let's call it so) that much.\n> I'd like to know is there any method (low-level I suppose, as far as Git\n> manages tree-objects as files) to make v2.4 LAST commit to be the\n> parent of v2.5 FIRST commit?\n> \nThis is impossible.\nThe commit-id is calculated from the history of the whole repository.\nSo you  must rebase in the sense of dependency on another history. \nMy  method  enables to rebase on the same content of the repository.\n"},{"id":"159330","messageId":"m3lj2rbmq5.fsf@localhost.localdomain","threadId":"26258","inReplyTo":"746745466.20110111134101@mail.ru","subject":"Re: Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-01-11T13:21:48Z","receivedAt":"2011-01-11T13:21:48Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"=?windows-1251?B?wOvl6vHl6SDY8+zq6O0=?= <zapped@mail.ru> writes:\n\n> 1.5 years ago I had sources of a project in a SVN repository (actually it does not\n> matter what SCM was used before). And I had two branches: v2.4 and v2.5.\n> They differed enough at that moment and (as usual for SVN branches)\n> laid in two different folders.\n> Then I had known of Git and I decided to try to use this powerful DVCS.\n> But as I was a newbie I created two git-repositories: one per each\n> branch. So v2.4 has its own git-repo. v2.5 (and above) has another one.\n> \n> Now I'd like to merge them as v2.5 was a continuos branch from v2.4,\n> but without a rebasing (i.e. without a global changing of v2.5\n> repository, which already has another branches)\n> It must look like LAST commit of v2.4 should be a PARENT of FIRST commit of v2.5\n> \n> Now there's a question: Is it possible to do so (no rebasing!), and If\n> \"yes\" then how to?\n\nAs Andreas Ericsson wrote, you can do this using grafts (and you can\nmake history with grafts permanent using \"git filter-branch\").\n\nBetter solution might be to use more modern replace mechanism, see\ne.g. \"git replace\" manpage.  Below there is untested step-by-step\ninstruction.\n\nFirst, you have put history of v2.4 and of v2.5 in a single repository\n(e.g. using \"git remote add\").  Then you need to find FIRST commit of\nv2.5 among\n\n  $ git rev-list master --parents | grep -v ' '\n\nThe above finds all parent-less commits in 'master' branch; replace it\nwith branch holding v2.5 history.  Then you need to find LAST commit\nof v2.4 and its SHA-1, e.g. via\n\n  $ git rev-parse v2.4\n\nSave current state of FIRST commit of v2.5 to a file\n\n  $ git cat-file -p FIRST > tmp\n\nEdit this file, adding 'parent' line between 'tree' and 'author'\nheaders, so the header of this file looks like the following:\n\n  tree 13d050266e05f7c66000240814199fcf3b559d43\n  parent ada9983c4256f5a7bac1f7f0e29d52011741d6aa\n  author Jakub Narebski <jnareb@gmail.com> 1294231771 +0100\n\n(trailing space added for better readibility).\n\nThen you need to add newly created object to repository:\n\n  $ git hash-object -t commit -w tmp\n\nand then use it as replacement\n\n  $ git replace <SHA-1 of FIRST> <SHA-1 returned by hash-object>\n\nFinally check that replacement works, e.g.:\n\n  $ git show FIRST\n  $ git log --graph --oneline -3 FIRST\n\nThe anyone who would fetch refs/replace/ would get joined history, and\nwho doesn't would see it not connected.\n\n\nP.S. This probably should made it into Documentation/howto\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"159341","messageId":"961742587.20110111174907@mail.ru","threadId":"26258","inReplyTo":"m3lj2rbmq5.fsf@localhost.localdomain","subject":"Re[2]: Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?","fromName":"Алексей Шумкин","fromEmail":"zapped@mail.ru","sentAt":"2011-01-11T14:49:07Z","receivedAt":"2011-01-11T14:49:07Z","isPatch":false,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"Hello, Jakub.\n\nThank you very much. Your method works great and it suits for me well\n\n>> 1.5 years ago I had sources of a project in a SVN repository (actually it does not\n>> matter what SCM was used before). And I had two branches: v2.4 and v2.5.\n>> They differed enough at that moment and (as usual for SVN branches)\n>> laid in two different folders.\n>> Then I had known of Git and I decided to try to use this powerful DVCS.\n>> But as I was a newbie I created two git-repositories: one per each\n>> branch. So v2.4 has its own git-repo. v2.5 (and above) has another one.\n>> \n>> Now I'd like to merge them as v2.5 was a continuos branch from v2.4,\n>> but without a rebasing (i.e. without a global changing of v2.5\n>> repository, which already has another branches)\n>> It must look like LAST commit of v2.4 should be a PARENT of FIRST commit of v2.5\n>> \n>> Now there's a question: Is it possible to do so (no rebasing!), and If\n>> \"yes\" then how to?\n\nJN> As Andreas Ericsson wrote, you can do this using grafts (and you can\nJN> make history with grafts permanent using \"git filter-branch\").\n\nJN> Better solution might be to use more modern replace mechanism, see\nJN> e.g. \"git replace\" manpage.  Below there is untested step-by-step\nJN> instruction.\n\nJN> First, you have put history of v2.4 and of v2.5 in a single repository\nJN> (e.g. using \"git remote add\").  Then you need to find FIRST commit of\nJN> v2.5 among\n\nJN>   $ git rev-list master --parents | grep -v ' '\n\nJN> The above finds all parent-less commits in 'master' branch; replace it\nJN> with branch holding v2.5 history.  Then you need to find LAST commit\nJN> of v2.4 and its SHA-1, e.g. via\n\nJN>   $ git rev-parse v2.4\n\nJN> Save current state of FIRST commit of v2.5 to a file\n\nJN>   $ git cat-file -p FIRST > tmp\n\nJN> Edit this file, adding 'parent' line between 'tree' and 'author'\nJN> headers, so the header of this file looks like the following:\n\nJN>   tree 13d050266e05f7c66000240814199fcf3b559d43\nJN>   parent ada9983c4256f5a7bac1f7f0e29d52011741d6aa\nJN>   author Jakub Narebski <jnareb@gmail.com> 1294231771 +0100\n\nJN> (trailing space added for better readibility).\n\nJN> Then you need to add newly created object to repository:\n\nJN>   $ git hash-object -t commit -w tmp\n\nJN> and then use it as replacement\n\nJN>   $ git replace <SHA-1 of FIRST> <SHA-1 returned by hash-object>\n\nJN> Finally check that replacement works, e.g.:\n\nJN>   $ git show FIRST\nJN>   $ git log --graph --oneline -3 FIRST\n\nJN> The anyone who would fetch refs/replace/ would get joined history, and\nJN> who doesn't would see it not connected.\n\n\nJN> P.S. This probably should made it into Documentation/howto\n"},{"id":"159342","messageId":"1208283037.20110111175801@mail.ru","threadId":"26258","inReplyTo":"4D2C500F.6070203@op5.se","subject":"Re[2]: Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?","fromName":"Алексей Шумкин","fromEmail":"zapped@mail.ru","sentAt":"2011-01-11T14:58:01Z","receivedAt":"2011-01-11T14:58:01Z","isPatch":false,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"\nAE> On 01/11/2011 01:33 PM, Алексей Шумкин wrote:\n>> Thank you for the answer, but it's not what I want ))\n>> Applying patches is the same as rebasing, I guess.\n>> But I do not want to change v2.5-repo (let's call it so) that much.\n>> I'd like to know is there any method (low-level I suppose, as far as Git\n>> manages tree-objects as files) to make v2.4 LAST commit to be the\n>> parent of v2.5 FIRST commit?\n>> \n\nAE> You want grafts. Check them up in the docs. Googling for \"git graft\"\nAE> should get you a good starting point.\n\nYes, you`re right, but unfortunately grafts ('info/grafts' file) cannot be cloned unless\n'git filter-branch' is executed, but this command changes all the\n\"v2.5-repo\" which is \"equivalent\" to 'git rebase' and what I aspire\nto avoid.\n\nBut Jakub Narebski <jnareb@gmail.com> gave a solution which suits for\nme great.\n\nThank you for your reply\n"},{"id":"159343","messageId":"694738910.20110111181656@mail.ru","threadId":"26258","inReplyTo":"m3lj2rbmq5.fsf@localhost.localdomain","subject":"Re[2]: Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible?","fromName":"Алексей Шумкин","fromEmail":"zapped@mail.ru","sentAt":"2011-01-11T15:16:56Z","receivedAt":"2011-01-11T15:16:56Z","isPatch":false,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"\nThere is one more method using grafts and fast-export/import\nhttp://ben.straubnet.net/post/939181602/git-grafting-repositories\n\nLet it be here too\n"},{"id":"159389","messageId":"20110112000812.GA31950@burratino","threadId":"26258","inReplyTo":"m3lj2rbmq5.fsf@localhost.localdomain","subject":"[RFC/PATCH] Documentation: start to explain what git replace is for","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-01-12T00:08:12Z","receivedAt":"2011-01-12T00:08:12Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jakub Narebski wrote:\n\n> P.S. This probably should made it into Documentation/howto\n\nOr even better, the git-replace manpage.  How about something like\nthis?  Still very rough.  I'd be happy if someone else can pick this\nup and make it into something better (for example, with an addition\nto the test suite to make sure we are not telling lies).\n\n-- 8< --\nSubject: Documentation: start to explain what git replace is for\n\nWith an example from Алексей Шумкин <zapped@mail.ru>.\n\nBased-on-message-by: Jakub Narebski <jnareb@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n Documentation/git-replace.txt |  106 +++++++++++++++++++++++++++++++----------\n 1 files changed, 80 insertions(+), 26 deletions(-)\n\ndiff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt\nindex fde2092..02e5de8 100644\n--- a/Documentation/git-replace.txt\n+++ b/Documentation/git-replace.txt\n@@ -14,38 +14,29 @@ SYNOPSIS\n \n DESCRIPTION\n -----------\n-Adds a 'replace' reference in `.git/refs/replace/`\n \n-The name of the 'replace' reference is the SHA1 of the object that is\n-replaced. The content of the 'replace' reference is the SHA1 of the\n-replacement object.\n+The `git replace <object> <replacement>` command adds a ref in the\n+`refs/replace/` hierarchy requesting that requests for <object> be\n+handled by retrieving <replacement> instead.  This is most commonly\n+used to replace one commit by another.\n \n-Unless `-f` is given, the 'replace' reference must not yet exist in\n-`.git/refs/replace/` directory.\n+The name of this 'replace' reference is the object id for the object\n+that is replaced.  Unless `-f` is given, the 'replace' reference must\n+not already exist in the `refs/replace/` hierarchy.\n \n-Replacement references will be used by default by all git commands\n-except those doing reachability traversal (prune, pack transfer and\n-fsck).\n+Replacement references will be used by default by most git commands,\n+with the notable exception of reachability calculations.  This\n+exception means that replacements do not affect the result of 'git gc'\n+or 'git clone', ensuring that (1) it is always safe to remove a\n+replacement reference without harming repository integrity and\n+(2) replacements do not change the meaning of 'have' lines during\n+pack transfer, so the client and server do not need to have the same\n+replacements during object transfer for it to succeed.\n \n It is possible to disable use of replacement references for any\n command using the `--no-replace-objects` option just after 'git'.\n-\n-For example if commit 'foo' has been replaced by commit 'bar':\n-\n-------------------------------------------------\n-$ git --no-replace-objects cat-file commit foo\n-------------------------------------------------\n-\n-shows information about commit 'foo', while:\n-\n-------------------------------------------------\n-$ git cat-file commit foo\n-------------------------------------------------\n-\n-shows information about commit 'bar'.\n-\n-The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to\n-achieve the same effect as the `--no-replace-objects` option.\n+Additionally, the 'GIT_NO_REPLACE_OBJECTS' environment variable can\n+be set to achieve the same effect.\n \n OPTIONS\n -------\n@@ -62,6 +53,69 @@ OPTIONS\n \tTyping \"git replace\" without arguments, also lists all replace\n \trefs.\n \n+EXAMPLES\n+--------\n+. The following sequence replaces commit 'foo' with commit 'bar'\n+and then views the replaced and unreplaced versions of 'foo'.\n++\n+------------------------------------------------\n+$ git replace foo^{commit} bar^{commit}        <1>\n+$ git --no-replace-objects cat-file commit foo <2>\n+$ git cat-file commit foo                      <3>\n+------------------------------------------------\n++\n+<1> request replacement\n+<2> show information about the true commit 'foo'\n+<3> show information about the replacement commit 'bar'\n+\n+. The following example comes from Алексей Шумкин:\n++\n+1.5 years ago I had sources of a project in another version control\n+system.  And I had two branches: v2.4 and v2.5.\n+They differed enough at that moment and laid in two different folders.\n+Then I learned about Git and I decided to try to use this DVCS.\n+I created two git repositories: one for each branch.\n+So v2.4 has its own git repo and v2.5 (and above) has another one.\n++\n+Now I'd like to merge them as v2.5 was a continuous branch from v2.4,\n+but without rebasing (i.e. without a global change to the v2.5\n+repository, which already has other branches).  It should look like\n+the last commit of from the v2.4 branch is a parent of the first\n+commit of v2.5.\n++\n+You can do this using grafts (and you can make history with grafts\n+permanent using 'git filter-branch').  A better solution might be to\n+use the more modern replace mechanism.  Below are untested step-by-step\n+instructions.\n++\n+--------------------------------------------------\n+$ git rev-list master --parents | grep -v ' '    <1>\n+$ git rev-parse v2.4                             <2>\n+$ git cat-file commit FIRST >tmp                 <3>\n+$ sed -i \"/^tree / a \\\\\n+parent $(git rev-parse v2.4)\" <tmp >new          <4>\n+$ git hash-object -t commit -w new               <5>\n+$ git replace FIRST <object id from hash-object> <6>\n+$ git show FIRST\n+$ git log --graph --oneline -3 FIRST             <7>\n+--------------------------------------------------\n++\n+<1> Find all parentless commits in the 'master' branch;\n+for 'master' read the branch holding v2.5 history.\n+<2> Find the last commit of v2.4.\n+<3> Save the current state of the first commit of v2.5 to a file.\n+<4> Edit this file, adding 'parent' line between 'tree' and 'author'\n+headers, so the header of this file looks like the following:\n+  tree 13d050266e05f7c66000240814199fcf3b559d43\n+  parent ada9983c4256f5a7bac1f7f0e29d52011741d6aa\n+  author Jakub Narebski <jnareb@gmail.com> 1294231771 +0100\n+<5> Add the newly created object to the repository.\n+<6> Use it as a replacement.\n+<7> Check that replacement works.\n++\n+Then anyone who fetches `refs/replace/*` will get the joined history,\n+and those who doesn't will see it not connected.\n+\n BUGS\n ----\n Comparing blobs or trees that have been replaced with those that\n-- \n1.7.4.rc1\n"},{"id":"159415","messageId":"loom.20110112T232501-316@post.gmane.org","threadId":"26258","inReplyTo":"20110112000812.GA31950@burratino","subject":"Re: [RFC/PATCH] Documentation: start to explain what git replace is for","fromName":"Maaartin","fromEmail":"grajcar1@seznam.cz","sentAt":"2011-01-12T22:47:31Z","receivedAt":"2011-01-12T22:47:31Z","isPatch":true,"sender":{"key":"grajcar1@seznam.cz","avatar":null},"body":"Jonathan Nieder <jrnieder <at> gmail.com> writes:\n\n> +. The following example comes from ??????? ??????:\n\nI know unicode exists already for many years, but in cygwin I get just a bunch \nof question marks instead of the name. So I'd suggest to replace \"Алексей \nШумкин\" by \"Alexej Shumkin\" or whatever his preferred transcription is.\n\n\n> +<1> Find all parentless commits in the 'master' branch;\n> +for 'master' read the branch holding v2.5 history.\n\nAren't you later calling it \"FIRST\" and assuming there's only one?\n\n> +$ sed -i \"/^tree / a \\\\\n> +parent $(git rev-parse v2.4)\" <tmp >new          <4>\n\nIsn't the combination of \"-i\" (=in-place edit) with redirection wrong? I hardly \nknow anything about sed (abandoned it in favor of perl many years ago).\n\n> +$ git hash-object -t commit -w new               <5>\n> +$ git replace FIRST <object id from hash-object> <6>\n\nI'd prefer something like\n\n+$ objectId=$(git hash-object -t commit -w new)\n+$ git replace FIRST $objectId\n\nThis is easier for people just willing to use it without much thinking, and \nalso for those having no idea that git-hash-object creates a new object.\n\nThat said, it's a nice example and I've learned quite a few things.\n"},{"id":"159433","messageId":"loom.20110113T084227-667@post.gmane.org","threadId":"26258","inReplyTo":"loom.20110112T232501-316@post.gmane.org","subject":"Re: [RFC/PATCH] Documentation: start to explain what git replace is for","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-01-13T07:52:06Z","receivedAt":"2011-01-13T07:52:06Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"Maaartin <grajcar1 <at> seznam.cz> writes:\n> I know unicode exists already for many years, but in cygwin I get just a bunch \n> of question marks instead of the name. So I'd suggest to replace \"Алексей \n> Шумкин\" by \"Alexej Shumkin\" or whatever his preferred transcription is.\n\n\"Alexey Shumkin\" I'd prefer ) (it can be noticed in the patche)\n\nI use email-client for this account primarily for Russian correspondents\nso the  signature is in Russian\n* \"Maybe that's the reason to know how \"The Bat!\" can change letter\ntemplates for particular recipients\" he thought *\n"},{"id":"159467","messageId":"20110114084903.GD11343@burratino","threadId":"26258","inReplyTo":"loom.20110112T232501-316@post.gmane.org","subject":"[RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-01-14T08:49:03Z","receivedAt":"2011-01-14T08:49:03Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Some tweaks suggested by Maaartin:\n\n- use a transliteration for Aleksey's name.  \n- clarify that there will only be one parentless commit in a typical\n  branch\n- use variables so the recipe is easier to test by copy and paste\n- remove unintended \"-i\" argument to sed\n\nWhile at it, make a few miscellaneous grammar tweaks and make sure\neach line of the example raw commit appears on a separate line.\nThe formatting is still not great for that --- there is too much\nspace between lines.\n\nStill to do: check whether this actually works and add a test script\nto make sure it keeps working.\n\nImproved-by: Maaartin <grajcar1@seznam.cz>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nCan be tested with\n\n\tmake -C Documentation git-replace.1\n\tman Documentation/git-replace.1\n\n.\n\nMaaartin wrote:\n> Jonathan Nieder writes:\n[side note: please do not prune the cc list; I only stumbled on this\nmessage in the online archive by luck]\n\n>> +. The following example comes from ??????? ??????:\n>\n> I know unicode exists already for many years, but in cygwin I get just a bunch \n> of question marks instead of the name. So I'd suggest to replace \"Алексей \n> Шумкин\" by \"Alexej Shumkin\" or whatever his preferred transcription is.\n\nMakes sense.\n\n>> +<1> Find all parentless commits in the 'master' branch;\n>> +for 'master' read the branch holding v2.5 history.\n>\n> Aren't you later calling it \"FIRST\" and assuming there's only one?\n\nHmm.  I want to say that there _could_ be multiple parentless commits\nin the v2.5 history and we are treating one of them as its root (just\nlike git master has multiple parentless ancestors but e83c5163 is\nconventionally considered its beginning).  Not sure how to write that\nclearly.\n\n> Isn't the combination of \"-i\" (=in-place edit) with redirection wrong?\n\nGood catch (the \"-i\" is a typo).\n\n> +$ objectId=$(git hash-object -t commit -w new)\n> +$ git replace FIRST $objectId\n>\n> This is easier for people just willing to use it without much thinking, and \n> also for those having no idea that git-hash-object creates a new object.\n\nRight, thanks.\n\n Documentation/git-replace.txt |   40 ++++++++++++++++++++++------------------\n 1 files changed, 22 insertions(+), 18 deletions(-)\n\ndiff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt\nindex 02e5de8..5829901 100644\n--- a/Documentation/git-replace.txt\n+++ b/Documentation/git-replace.txt\n@@ -68,16 +68,17 @@ $ git cat-file commit foo                      <3>\n <2> show information about the true commit 'foo'\n <3> show information about the replacement commit 'bar'\n \n-. The following example comes from Алексей Шумкин:\n+. The following example comes from Aleksey Shumkin:\n +\n 1.5 years ago I had sources of a project in another version control\n system.  And I had two branches: v2.4 and v2.5.\n-They differed enough at that moment and laid in two different folders.\n+They differed enough at that moment and lay in two different folders.\n Then I learned about Git and I decided to try to use this DVCS.\n I created two git repositories: one for each branch.\n-So v2.4 has its own git repo and v2.5 (and above) has another one.\n+So v2.4 has one git repo and v2.5 (and above) has another one.\n +\n-Now I'd like to merge them as v2.5 was a continuous branch from v2.4,\n+Now I'd like to merge them as if v2.5 were a continuous development\n+from v2.4,\n but without rebasing (i.e. without a global change to the v2.5\n repository, which already has other branches).  It should look like\n the last commit of from the v2.4 branch is a parent of the first\n@@ -89,25 +90,28 @@ use the more modern replace mechanism.  Below are untested step-by-step\n instructions.\n +\n --------------------------------------------------\n-$ git rev-list master --parents | grep -v ' '    <1>\n-$ git rev-parse v2.4                             <2>\n-$ git cat-file commit FIRST >tmp                 <3>\n-$ sed -i \"/^tree / a \\\\\n-parent $(git rev-parse v2.4)\" <tmp >new          <4>\n-$ git hash-object -t commit -w new               <5>\n-$ git replace FIRST <object id from hash-object> <6>\n-$ git show FIRST\n-$ git log --graph --oneline -3 FIRST             <7>\n+$ git rev-list master --parents | grep -v ' '\n+$ first=$(git rev-list master --parents | grep -v ' ') <1>\n+$ git rev-parse v2.4                                   <2>\n+$ git cat-file commit $first >tmp                      <3>\n+$ sed \"/^tree / a \\\\\n+parent $(git rev-parse v2.4)\" <tmp >new                <4>\n+$ new_commit=$(git hash-object -t commit -w new)       <5>\n+$ git replace $first $new_commit                       <6>\n+$ git show $first\n+$ git log --graph --oneline -3 $first                  <7>\n --------------------------------------------------\n +\n-<1> Find all parentless commits in the 'master' branch;\n-for 'master' read the branch holding v2.5 history.\n+<1> List all parentless commits in the 'master' branch and\n+call the appropriate one (in this case the only one) $first.\n+Instead of 'master' one would use the branch holding v2.5\n+history.\n <2> Find the last commit of v2.4.\n <3> Save the current state of the first commit of v2.5 to a file.\n <4> Edit this file, adding 'parent' line between 'tree' and 'author'\n-headers, so the header of this file looks like the following:\n-  tree 13d050266e05f7c66000240814199fcf3b559d43\n-  parent ada9983c4256f5a7bac1f7f0e29d52011741d6aa\n+headers, so the header of this file looks like the following: +\n+  tree 13d050266e05f7c66000240814199fcf3b559d43 +\n+  parent ada9983c4256f5a7bac1f7f0e29d52011741d6aa +\n   author Jakub Narebski <jnareb@gmail.com> 1294231771 +0100\n <5> Add the newly created object to the repository.\n <6> Use it as a replacement.\n-- \n1.7.4.rc2\n"},{"id":"159500","messageId":"4D308B69.1050003@seznam.cz","threadId":"26258","inReplyTo":"20110114084903.GD11343@burratino","subject":"Re: [RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for","fromName":"Maaartin-1","fromEmail":"grajcar1@seznam.cz","sentAt":"2011-01-14T17:44:09Z","receivedAt":"2011-01-14T17:44:09Z","isPatch":true,"sender":{"key":"grajcar1@seznam.cz","avatar":null},"body":"On 11-01-14 09:49, Jonathan Nieder wrote:\n> Some tweaks suggested by Maaartin:\n\n[snip]\n\n> [side note: please do not prune the cc list; I only stumbled on this\n> message in the online archive by luck]\n\nWhat could I have done about it? I didn't received it by email and\nanswered using post.gmane.org. There's no way to add CC there. If I'd\nwrote an email instead, it wouldn't be placed in the thread.\n\n[snip]\n\n>>> +<1> Find all parentless commits in the 'master' branch;\n>>> +for 'master' read the branch holding v2.5 history.\n>>\n>> Aren't you later calling it \"FIRST\" and assuming there's only one?\n> \n> Hmm.  I want to say that there _could_ be multiple parentless commits\n> in the v2.5 history and we are treating one of them as its root (just\n> like git master has multiple parentless ancestors but e83c5163 is\n> conventionally considered its beginning).  Not sure how to write that\n> clearly.\n\nMaybe just something like \"Let's assume there's only one and let's call\nit FIRST\". For the example, this is enough.\n\n>> Isn't the combination of \"-i\" (=in-place edit) with redirection wrong?\n> \n> Good catch (the \"-i\" is a typo).\n\nI'd go the other way round and use \"-i\" so I'd need only one file. Using\na shell variable instead would be even better, s. below.\n\n[snip]\n\nI tried to use the vars instead of files below, but never tested it. I\nused \"first_commit\" instead of both \"tmp\" and \"new\", which is not really\nnice.\n\n> +$ git rev-list master --parents | grep -v ' '\n> +$ first=$(git rev-list master --parents | grep -v ' ') <1>\n> +$ git rev-parse v2.4                                   <2>\n> +$ git cat-file commit $first >tmp                      <3>\n\n$ first_commit = $(git cat-file commit FIRST)       <3>\n\n> +$ sed \"/^tree / a \\\\\n> +parent $(git rev-parse v2.4)\" <tmp >new                <4>\n\n$ first_commit = $($ echo $first_commit |\nsed  \"/^tree / a \\\\\nparent $(git rev-parse v2.4)\")                      <4>\n\nUnfortunately, the line got too long. For sed unaware people like me it\nmay not be obvious that a line break is required. I'd use perl, anyway.\n\n$ first_commit = $($ echo $first_commit |\nperl -p\n\"s/^tree .*/$&\\nparent $(git rev-parse v2.4)/\")      <4>\n\n> +$ new_commit=$(git hash-object -t commit -w new)       <5>\n\n$ new_commit=$(echo $first_commit |\ngit hash-object -t commit -w --stdin)       <5>\n\n[snip]\n"},{"id":"159503","messageId":"20110114193023.GA14294@burratino","threadId":"26258","inReplyTo":"4D308B69.1050003@seznam.cz","subject":"Re: [RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-01-14T19:30:23Z","receivedAt":"2011-01-14T19:30:23Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Maaartin wrote:\n> On 11-01-14 09:49, Jonathan Nieder wrote:\n\n>> [side note: please do not prune the cc list; I only stumbled on this\n>> message in the online archive by luck]\n>\n> What could I have done about it?\n\nSee [1].\n\n> Maybe just something like \"Let's assume there's only one and let's call\n> it FIRST\". For the example, this is enough.\n\nTrue enough.  Even better would be to give a reference to the \"coolest merge\never\" (is that documented anywhere?) so the interested reader can discover\nhow there could be more than one.\n\n> I'd go the other way round and use \"-i\" so I'd need only one file.\n\n\"sed -i\" is not portable (not sure how important that is for documentation).\nBut perl -i is. :)\n\n> $ first_commit = $($ echo $first_commit |\n> perl -p\n> \"s/^tree .*/$&\\nparent $(git rev-parse v2.4)/\")      <4>\n\nSo:\n\n\tperl -pi -e \"s/^tree .*$/\\$&\\nparent $(git rev-parse v2.4)/\" new\n\nUnfortunately \"echo\" and process substitution destroy some formatting\nin the commit message --- in particular, trailing whitespace.\n\nThanks for the suggestions.  Please feel free to pick up the patch and\nrun with it (I trust you for this more than I would trust myself).\n\nRegards,\nJonathan\n\n[1] My current method: [2]  Yes, I agree that this is cumbersome.\n\nI'm also told that Thunderbird when used as a newsreader can reply-to-all\neasily, though I haven't tried it.\n\n[2] http://thread.gmane.org/gmane.comp.version-control.git/154490\n"},{"id":"159508","messageId":"20110114210926.GB15286@burratino","threadId":"26258","inReplyTo":"20110114193023.GA14294@burratino","subject":"how multiple roots happen (Re: [RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for)","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-01-14T21:09:26Z","receivedAt":"2011-01-14T21:09:26Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jonathan Nieder wrote:\n> Maaartin wrote:\n\n>> Maybe just something like \"Let's assume there's only one and let's call\n>> it FIRST\". For the example, this is enough.\n>\n> True enough.  Even better would be to give a reference to the \"coolest merge\n> ever\" (is that documented anywhere?) so the interested reader can discover\n> how there could be more than one.\n\nApparently it was not clear what I was talking about (who knew?).  So\nhere you go:\n\n http://thread.gmane.org/gmane.comp.version-control.git/5126\n\nFor a more modern take on it:\n\n http://thread.gmane.org/gmane.comp.version-control.git/144302/focus=144323\n"},{"id":"159514","messageId":"201101142348.31647.jnareb@gmail.com","threadId":"26258","inReplyTo":"4D308B69.1050003@seznam.cz","subject":"Re: [RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-01-14T22:48:30Z","receivedAt":"2011-01-14T22:48:30Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Fri, 14 Jan 2011, Maaartin-1 wrote:\n> On 11-01-14 09:49, Jonathan Nieder wrote:\n> > Some tweaks suggested by Maaartin:\n> \n> [snip]\n> \n>> [side note: please do not prune the cc list; I only stumbled on this\n>> message in the online archive by luck]\n> \n> What could I have done about it? I didn't received it by email and\n> answered using post.gmane.org. There's no way to add CC there. If I'd\n> wrote an email instead, it wouldn't be placed in the thread.\n\nIn a good newsreader, like e.g. Gnus from GNU Emacs, you have option\nto do 'reply all via email', which includes also git@vger.kernel.org,\ni.e. mailing list from which gmane newsgroup is created.  That's what\nI do nowadays (usually).\n\n> [snip]\n> \n>>>> +<1> Find all parentless commits in the 'master' branch;\n>>>> +for 'master' read the branch holding v2.5 history.\n>>>\n>>> Aren't you later calling it \"FIRST\" and assuming there's only one?\n>> \n>> Hmm.  I want to say that there _could_ be multiple parentless commits\n>> in the v2.5 history and we are treating one of them as its root (just\n>> like git master has multiple parentless ancestors but e83c5163 is\n>> conventionally considered its beginning).  Not sure how to write that\n>> clearly.\n> \n> Maybe just something like \"Let's assume there's only one and let's call\n> it FIRST\". For the example, this is enough.\n\nThat might be good enough, as I don't think that at beginning (where you\nare creating current and archive repository) one would have multiple roots\nfrom joining separate projects.\n \n>>> Isn't the combination of \"-i\" (=in-place edit) with redirection wrong?\n>> \n>> Good catch (the \"-i\" is a typo).\n> \n> I'd go the other way round and use \"-i\" so I'd need only one file. Using\n> a shell variable instead would be even better, s. below.\n\nNo, using shell variable for storing commit object is *not* a good idea.\nEither save it to temporary file, where you can edit it using editor of\nyour choice, or use pipeline.\n \n> [snip]\n> \n> I tried to use the vars instead of files below, but never tested it. I\n> used \"first_commit\" instead of both \"tmp\" and \"new\", which is not really\n> nice.\n> \n>> +$ git rev-list master --parents | grep -v ' '\n>> +$ first=$(git rev-list master --parents | grep -v ' ') <1>\n\nOr using always the oldest commit:\n\n   +$ first=$(git rev-list master --date-order --parents | grep -v ' ' | tail -1) <1>\n\n\n>> +$ git rev-parse v2.4                                   <2>\n\nLet's save it to a variable too\n\n   +$ join=$(git rev-parse v2.4)                           <2>\n\n\n>> +$ git cat-file commit $first >tmp                      <3>\n\nWe can use COMMIT, or even FIRST as a file name here.\n\n> $ first_commit = $(git cat-file commit FIRST)            <3>\n\nNo.  Just... no.\n\n> > +$ sed \"/^tree / a \\\\\n> > +parent $(git rev-parse v2.4)\" <tmp >new                <4>\n> \n> $ first_commit = $($ echo $first_commit |\n> sed  \"/^tree / a \\\\\n> parent $(git rev-parse v2.4)\")                      <4>\n> \n> Unfortunately, the line got too long. For sed unaware people like me it\n> may not be obvious that a line break is required.\n\nNo, it is not required, I think.\n\n> I'd use perl, anyway. \n> \n> $ first_commit = $($ echo $first_commit |\n> perl -p\n> \"s/^tree .*/$&\\nparent $(git rev-parse v2.4)/\")      <4>\n> \n> > +$ new_commit=$(git hash-object -t commit -w new)       <5>\n> \n> $ new_commit=$(echo $first_commit |\n> git hash-object -t commit -w --stdin)       <5>\n\nIf you don't use temporary file, which you can edit, you can use pipeline\ninstead:\n\n  $ new_commit=$(git cat-file commit $first_commit |\n                 sed -e \"/^tree / a\\\\parent $(git rev-parse v2.4)\" |\n                 git hash-object -t commit -w --stdin\n\n  $ git replace $first_commit $new_commit\n\n-- \nJakub Narebski\nPoland\n"},{"id":"159515","messageId":"4D30E48C.4060400@seznam.cz","threadId":"26258","inReplyTo":"201101142348.31647.jnareb@gmail.com","subject":"Re: [RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for","fromName":"Maaartin-1","fromEmail":"grajcar1@seznam.cz","sentAt":"2011-01-15T00:04:28Z","receivedAt":"2011-01-15T00:04:28Z","isPatch":true,"sender":{"key":"grajcar1@seznam.cz","avatar":null},"body":"On 11-01-14 23:48, Jakub Narebski wrote:\n> On Fri, 14 Jan 2011, Maaartin-1 wrote:\n>> On 11-01-14 09:49, Jonathan Nieder wrote:\n>>> Some tweaks suggested by Maaartin:\n\n>>> [side note: please do not prune the cc list; I only stumbled on this\n>>> message in the online archive by luck]\n>>\n>> What could I have done about it? I didn't received it by email and\n>> answered using post.gmane.org. There's no way to add CC there. If I'd\n>> wrote an email instead, it wouldn't be placed in the thread.\n> \n> In a good newsreader, like e.g. Gnus from GNU Emacs, you have option\n> to do 'reply all via email', which includes also git@vger.kernel.org,\n> i.e. mailing list from which gmane newsgroup is created.  That's what\n> I do nowadays (usually).\n\nI hate using Emacs for too many things. However, I'm starting to use\nThunderbird as newsreader, and it's quite OK.\n\n>> I'd go the other way round and use \"-i\" so I'd need only one file. Using\n>> a shell variable instead would be even better, s. below.\n> \n> No, using shell variable for storing commit object is *not* a good idea.\n> Either save it to temporary file, where you can edit it using editor of\n> your choice, or use pipeline.\n\nI see that the line-breaks get (for whatever reason) replaced by blanks,\nsorry for the noise.\n\n>>> +$ sed \"/^tree / a \\\\\n>>> +parent $(git rev-parse v2.4)\" <tmp >new                <4>\n>>\n>> $ first_commit = $($ echo $first_commit |\n>> sed  \"/^tree / a \\\\\n>> parent $(git rev-parse v2.4)\")                      <4>\n>>\n>> Unfortunately, the line got too long. For sed unaware people like me it\n>> may not be obvious that a line break is required.\n> \n> No, it is not required, I think.\n\nYou're right, sorry again.\n\n> If you don't use temporary file, which you can edit, you can use pipeline\n> instead:\n> \n>   $ new_commit=$(git cat-file commit $first_commit |\n>                  sed -e \"/^tree / a\\\\parent $(git rev-parse v2.4)\" |\n>                  git hash-object -t commit -w --stdin\n> \n>   $ git replace $first_commit $new_commit\n\nI know, I just thought, using such a pipe is not very enlightening, but\nit's actually quite easy to follow.\n"}]}