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

Re: [wishlist] git branch -d -r remotename

From
Junio C Hamano <junkio@cox.net>
Date
Mar 19, 2007, 06:40 UTC
Message-ID
<7v4pohka7g.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7v8xdtkb7p.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 17 quoted lines
> The standard way to check if commit A is included in (i.e. is an
> ancestor of) commit B, without traversing the ancestry chain of
> B all the way down to the root commit, is to run:
>
> 	git merge-base --all A B
>
> and see if A appears in its output (if so, then A is an ancestor
> of B, otherwise it is not).  This is a pair-wise check, and for
> your purpose the check would become N*M operation (Yuck).
>
> The same check can be done in parallel with:
>
> 	git show-branch --independent A B C D...
>
> whose output would include A if the commit is not included in
> any of the other commits B C D...  This parallel traversal has a
> limit --- you can only check 25 branches at a time.

Well, I was silly. If you want to see if A is an ancestor of any of B C D..., the standard and most efficient way to do so is with rev-list.

	git rev-list A --not B C D...

will show _nothing_ only when A is an ancestor of one (or more) of B C D..., so you invoke it and upon getting the first line of output you declare A cannot be removed without reading the remainder of the output.

show-branch --independent is an overkill for your purpose as it does not treat A any more special from others (iow, it checks if B is contained in A C D..., C is contained in A B D... all in parallel), and you are not interested in finding out how remote refs are related with each other.

Previous: Junio C HamanoNext: Sam Vilain
Message 7 of 8 in “[wishlist] git branch -d -r remotename”
  1. Sam VilainMar 18, 2007
  2. Sam VilainMar 18, 2007
  3. Sam VilainMar 18, 2007
  4. Junio C HamanoMar 18, 2007
  5. Sam VilainMar 18, 2007
  6. Junio C HamanoMar 19, 2007
  7. Junio C HamanoMar 19, 2007
  8. (unknown)Sam Vilain, Mar 19, 2007

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.