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

Speed of git branch --contains

From
Andreas Krey <a.krey@gmx.de>
Date
Jan 23, 2018, 20:36 UTC
Message-ID
<20180123203656.GA27016@inner.h.apk.li>
Hi everybody,

I'm just looking at some scripts that do a 'git branch --contains $id --remote' for each new commit in a repo, and unfortunately each invokation already takes four minutes.

It feels like git branch does the reachability detection separately for each branch potentially listed. The alternative would be to

- invert the parent map to a child map,
- use that to compute the set of commits that contain $id,
- then use that as predicate whether to show a given branch
  (show iff its head is in the set)

That would speed things up considerably, but what are the chances to see that change in git?

I can do that as well within the script, with the additional benefit that I only need to do the inversion once, but I might instead take a stab at git branch.

- Andreas
-- 
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
Next: Ævar Arnfjörð Bjarmason
Message 1 of 2 in “Speed of git branch --contains”
  1. Andreas KreyJan 23, 2018
  2. Ævar Arnfjörð BjarmasonJan 24, 2018

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.