Re: simple cvs-like git wrapper
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- Jan 31, 2008, 06:01 UTC
- Message-ID
- <20080131060136.GZ24004@spearce.org>
- In-Reply-To
- <20080131054124.GG9612@venus>
"Ed S. Peschko" <esp5@pge.com> wrote:
Show 12 quoted lines
> > This is going to be slow as you are running git-merge for each > > and every branch available to you. You can do a lot better by > > loading the branch DAG into memory in Perl/C/Python and doing a > > graph coloring algorithm to see if a merge is necessary or not, > > as if you are merging everything all of the time almost everything > > is going to be always merged to everything else. Which as I said > > earlier is nuts. > > hmm. Is there a simple method to get this graph? I'm assuming that you > would have to get all the local commits and compare them to the remote > commits, and only merge the branches that have commits not yet > merged..
Something along these lines:
%remotes = \ git for-each-ref \ --format='%(objname) %(refname)' \ refs/remotes/origin;
@lines = \ git rev-list \ keys %remotes \ --not HEAD
foreach $line in @lines {
if $remotes contains $line
git merge $remotes{$line}
}That gets you the graph. The %(objname) string coming back from for-each-ref is in $line in the loop. If you see $line inside that map you built from for-each-ref then that commit isn't yet in the current branch. So you'd then want to merge that commit.
-- Shawn.