git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Ed S. PeschkoNext: Junio C Hamano
Message 8 of 15 in “simple cvs-like git wrapper”
  1. Ed S. PeschkoJan 29, 2008
  2. Jakub NarebskiJan 29, 2008
  3. Ed S. PeschkoJan 30, 2008
  4. Shawn O. PearceJan 30, 2008
  5. Ed S. PeschkoJan 30, 2008
  6. Shawn O. PearceJan 31, 2008
  7. Ed S. PeschkoJan 31, 2008
  8. Shawn O. PearceJan 31, 2008
  9. Junio C HamanoJan 31, 2008
  10. Daniel BarkalowJan 30, 2008
  11. Kate RhodesFeb 1, 2008
  12. Johannes SchindelinFeb 1, 2008
  13. Jakub NarebskiFeb 1, 2008
  14. Uwe Kleine-KönigFeb 1, 2008
  15. Jakub NarebskiFeb 1, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.