git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: "Ed S. Peschko" <esp5@pge.com>
Cc: Jakub Narebski <jnareb@gmail.com>, git@vger.kernel.org
Subject: Re: simple cvs-like git wrapper
Date: Thu, 31 Jan 2008 01:01:37 -0500	[thread overview]
Message-ID: <20080131060136.GZ24004@spearce.org> (raw)
In-Reply-To: <20080131054124.GG9612@venus>

"Ed S. Peschko" <esp5@pge.com> wrote:
> > 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.

  reply	other threads:[~2008-01-31  6:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-29 20:40 simple cvs-like git wrapper Ed S. Peschko
2008-01-29 22:28 ` Jakub Narebski
2008-01-30  2:10   ` Ed S. Peschko
2008-01-30  4:00     ` Shawn O. Pearce
2008-01-30 22:52       ` Ed S. Peschko
2008-01-31  4:08         ` Shawn O. Pearce
2008-01-31  5:41           ` Ed S. Peschko
2008-01-31  6:01             ` Shawn O. Pearce [this message]
2008-01-31  6:17           ` Junio C Hamano
2008-01-30 19:49     ` Daniel Barkalow
2008-02-01 13:05     ` Kate Rhodes
2008-02-01 13:25       ` Johannes Schindelin
2008-02-01 15:35     ` Jakub Narebski
2008-02-01  7:29   ` Uwe Kleine-König
2008-02-01  9:58     ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080131060136.GZ24004@spearce.org \
    --to=spearce@spearce.org \
    --cc=esp5@pge.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).