{"thread":{"id":"8852","subject":"efficient way to filter several branches with common history?","startedAt":"2007-07-04T08:11:55Z","lastAt":"2007-07-04T14:28:15Z","messageCount":4,"participants":["Steffen Prohaska","Johannes Sixt","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"46451","messageId":"652B0F85-D0E4-4BF0-8DFC-212B6C0650AF@zib.de","threadId":"8852","inReplyTo":null,"subject":"efficient way to filter several branches with common history?","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-07-04T08:11:55Z","receivedAt":"2007-07-04T08:11:55Z","isPatch":false,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"Is there an efficient way to filter several branches at once\nthrough git-filter-branch? Often several branches have a lot\nof common history. Therefore, I suspect it would be much more\nefficient to filter them with one call to git-filter-branch.\nFor example how can I efficiently filter all origin/* branches\nto filtered/* branches?\n\n\tSteffen\n"},{"id":"46454","messageId":"468B5C4B.26F5E90B@eudaptics.com","threadId":"8852","inReplyTo":"652B0F85-D0E4-4BF0-8DFC-212B6C0650AF@zib.de","subject":"Re: efficient way to filter several branches with common history?","fromName":"Johannes Sixt","fromEmail":"j.sixt@eudaptics.com","sentAt":"2007-07-04T08:37:31Z","receivedAt":"2007-07-04T08:37:31Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Steffen Prohaska wrote:\n> \n> Is there an efficient way to filter several branches at once\n> through git-filter-branch? Often several branches have a lot\n> of common history. Therefore, I suspect it would be much more\n> efficient to filter them with one call to git-filter-branch.\n> For example how can I efficiently filter all origin/* branches\n> to filtered/* branches?\n\nThat feature is not yet implemented.\n\nIn the meantime do it this way:\n\nMake an octopus merge of the branches onto a new branch. (If you have\nmore than a dozen or so, you better make a hierarchy of octopusses.) You\ndon't need to resolve conflicts (you are not interested in the merge\nresult), or use -s ours to avoid them in the first place.\nThen filter that new branch.\nThen create new refs at the rewritten commits:\n\n   $ git update-ref refs/filtered/b1 $id-of-rewritten-origin/b1\n   $ ...\n\nUse gitk to find the $ids-of-rewritten-origin/*\n\n-- Hannes\n"},{"id":"46482","messageId":"6DC0E50A-CAD3-453E-BD9C-73E51EDD5785@zib.de","threadId":"8852","inReplyTo":"468B5C4B.26F5E90B@eudaptics.com","subject":"Re: efficient way to filter several branches with common history?","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-07-04T13:27:24Z","receivedAt":"2007-07-04T13:27:24Z","isPatch":false,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Jul 4, 2007, at 10:37 AM, Johannes Sixt wrote:\n\n> Steffen Prohaska wrote:\n>>\n>> Is there an efficient way to filter several branches at once\n>> through git-filter-branch? Often several branches have a lot\n>> of common history. Therefore, I suspect it would be much more\n>> efficient to filter them with one call to git-filter-branch.\n>> For example how can I efficiently filter all origin/* branches\n>> to filtered/* branches?\n>\n> That feature is not yet implemented.\n>\n> In the meantime do it this way:\n>\n> Make an octopus merge of the branches onto a new branch. (If you have\n> more than a dozen or so, you better make a hierarchy of  \n> octopusses.) You\n> don't need to resolve conflicts (you are not interested in the merge\n> result), or use -s ours to avoid them in the first place.\n> Then filter that new branch.\n> Then create new refs at the rewritten commits:\n>\n>    $ git update-ref refs/filtered/b1 $id-of-rewritten-origin/b1\n>    $ ...\n>\n> Use gitk to find the $ids-of-rewritten-origin/*\n\nThanks for your explanation. The following is the template I used\nto build my fully automated version of what you proposed:\n\n--- SNIP ---\necho \"merging branches to be filtered ...\"\ngit-checkout -b tmp/all origin/master\n\nfor b in origin/branchX origin/branchY [ ... more branches here ...]\ndo\n     git merge -s ours -m \"merge-for-preparing-filter-branch $b\" $b\ndone\n\necho \"... filtering ...\"\ngit-filter-branch \\\n[... your git-filter-branch filters here ...] \\\n   filtered/all >filter-branch.log\n\necho \"... setting heads of filtered branches.\"\nlastp1=\ngit-log --pretty=\"format:%s %P\" filtered/all |\nwhile read t b p1 p2\ndo\n     [[ \"$t\" == \"merge-for-preparing-filter-branch\" ]] || { git  \nupdate-ref refs/heads/filtered/master $lastp1 ; break ; }\n     b=filtered/$(basename $b)\n     git update-ref refs/heads/$b $p2\n     lastp1=$p1\ndone\n\necho \"delete tmp/all and filtered/all after checking the result\"\n--- SNIP ---\n\n\tSteffen\n"},{"id":"46487","messageId":"Pine.LNX.4.64.0707041527050.4071@racer.site","threadId":"8852","inReplyTo":"6DC0E50A-CAD3-453E-BD9C-73E51EDD5785@zib.de","subject":"Re: efficient way to filter several branches with common history?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-04T14:28:15Z","receivedAt":"2007-07-04T14:28:15Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 4 Jul 2007, Steffen Prohaska wrote:\n\n> On Jul 4, 2007, at 10:37 AM, Johannes Sixt wrote:\n> \n> > Steffen Prohaska wrote:\n> > > \n> > > Is there an efficient way to filter several branches at once\n> > > through git-filter-branch?\n> > \n> > That feature is not yet implemented.\n> > \n> > In the meantime do it this way:\n> > \n> > [...]\n> \n> Thanks for your explanation. The following is the template I used\n> to build my fully automated version of what you proposed:\n> \n> [...]\n\nSince you seem quite proficient in shell, why not implement this feature \nin filter-branch (which is a shell script) to begin with?\n\nCiao,\nDscho\n"}]}