git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* efficient way to filter several branches with common history?
@ 2007-07-04  8:11 Steffen Prohaska
  2007-07-04  8:37 ` Johannes Sixt
  0 siblings, 1 reply; 4+ messages in thread
From: Steffen Prohaska @ 2007-07-04  8:11 UTC (permalink / raw)
  To: Git Mailing List

Is there an efficient way to filter several branches at once
through git-filter-branch? Often several branches have a lot
of common history. Therefore, I suspect it would be much more
efficient to filter them with one call to git-filter-branch.
For example how can I efficiently filter all origin/* branches
to filtered/* branches?

	Steffen

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: efficient way to filter several branches with common history?
  2007-07-04  8:11 efficient way to filter several branches with common history? Steffen Prohaska
@ 2007-07-04  8:37 ` Johannes Sixt
  2007-07-04 13:27   ` Steffen Prohaska
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Sixt @ 2007-07-04  8:37 UTC (permalink / raw)
  To: git

Steffen Prohaska wrote:
> 
> Is there an efficient way to filter several branches at once
> through git-filter-branch? Often several branches have a lot
> of common history. Therefore, I suspect it would be much more
> efficient to filter them with one call to git-filter-branch.
> For example how can I efficiently filter all origin/* branches
> to filtered/* branches?

That feature is not yet implemented.

In the meantime do it this way:

Make an octopus merge of the branches onto a new branch. (If you have
more than a dozen or so, you better make a hierarchy of octopusses.) You
don't need to resolve conflicts (you are not interested in the merge
result), or use -s ours to avoid them in the first place.
Then filter that new branch.
Then create new refs at the rewritten commits:

   $ git update-ref refs/filtered/b1 $id-of-rewritten-origin/b1
   $ ...

Use gitk to find the $ids-of-rewritten-origin/*

-- Hannes

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: efficient way to filter several branches with common history?
  2007-07-04  8:37 ` Johannes Sixt
@ 2007-07-04 13:27   ` Steffen Prohaska
  2007-07-04 14:28     ` Johannes Schindelin
  0 siblings, 1 reply; 4+ messages in thread
From: Steffen Prohaska @ 2007-07-04 13:27 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Git Mailing List


On Jul 4, 2007, at 10:37 AM, Johannes Sixt wrote:

> Steffen Prohaska wrote:
>>
>> Is there an efficient way to filter several branches at once
>> through git-filter-branch? Often several branches have a lot
>> of common history. Therefore, I suspect it would be much more
>> efficient to filter them with one call to git-filter-branch.
>> For example how can I efficiently filter all origin/* branches
>> to filtered/* branches?
>
> That feature is not yet implemented.
>
> In the meantime do it this way:
>
> Make an octopus merge of the branches onto a new branch. (If you have
> more than a dozen or so, you better make a hierarchy of  
> octopusses.) You
> don't need to resolve conflicts (you are not interested in the merge
> result), or use -s ours to avoid them in the first place.
> Then filter that new branch.
> Then create new refs at the rewritten commits:
>
>    $ git update-ref refs/filtered/b1 $id-of-rewritten-origin/b1
>    $ ...
>
> Use gitk to find the $ids-of-rewritten-origin/*

Thanks for your explanation. The following is the template I used
to build my fully automated version of what you proposed:

--- SNIP ---
echo "merging branches to be filtered ..."
git-checkout -b tmp/all origin/master

for b in origin/branchX origin/branchY [ ... more branches here ...]
do
     git merge -s ours -m "merge-for-preparing-filter-branch $b" $b
done

echo "... filtering ..."
git-filter-branch \
[... your git-filter-branch filters here ...] \
   filtered/all >filter-branch.log

echo "... setting heads of filtered branches."
lastp1=
git-log --pretty="format:%s %P" filtered/all |
while read t b p1 p2
do
     [[ "$t" == "merge-for-preparing-filter-branch" ]] || { git  
update-ref refs/heads/filtered/master $lastp1 ; break ; }
     b=filtered/$(basename $b)
     git update-ref refs/heads/$b $p2
     lastp1=$p1
done

echo "delete tmp/all and filtered/all after checking the result"
--- SNIP ---

	Steffen

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: efficient way to filter several branches with common history?
  2007-07-04 13:27   ` Steffen Prohaska
@ 2007-07-04 14:28     ` Johannes Schindelin
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2007-07-04 14:28 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: Johannes Sixt, Git Mailing List

Hi,

On Wed, 4 Jul 2007, Steffen Prohaska wrote:

> On Jul 4, 2007, at 10:37 AM, Johannes Sixt wrote:
> 
> > Steffen Prohaska wrote:
> > > 
> > > Is there an efficient way to filter several branches at once
> > > through git-filter-branch?
> > 
> > That feature is not yet implemented.
> > 
> > In the meantime do it this way:
> > 
> > [...]
> 
> Thanks for your explanation. The following is the template I used
> to build my fully automated version of what you proposed:
> 
> [...]

Since you seem quite proficient in shell, why not implement this feature 
in filter-branch (which is a shell script) to begin with?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-07-04 14:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-04  8:11 efficient way to filter several branches with common history? Steffen Prohaska
2007-07-04  8:37 ` Johannes Sixt
2007-07-04 13:27   ` Steffen Prohaska
2007-07-04 14:28     ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).