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

Re: [PATCH 6/8] commit: provide a fast multi-tip contains function

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 26, 2014, 19:19 UTC
Message-ID
<xmqqha374gx3.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqtx774i1r.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 19 quoted lines
> The only time you can say "Ah, we've seen this one and no need to
> dig further" is when you are propagating a colour C and the parent
> in question is already painted in C (it is OK to be painted as
> reachable from more tips), I would think, so shouldn't the loop be
> more like, after painting each tip and placing it in the queue:
>
>  * Dequeue one, check the L/R bits in it and call that C
>
>  * Iterate over its parents P:
>
>    * check the L/R bits in P and call that Cp.
>
>    * If Cp is already a superset of C, there is no point putting P
>      to the queue to be processed.
>
>    * If Cp is not a superset of C, then update L/R bits in P to mark
>      it reachable from tips represented by C and put P to the queue.
>
> until you ran out of queue?

Actually that will cause you to dig down to the root, so it won't be nice.

If you are trying to do "branch --with $commit", what you would want is not exactly "paint-down-to-common(all branches, $commit)", but something that paints down to $commit from all branches, with an optimization that cuts off the traversal at a commit that is reachable from $commit. If a traversal from branch B reached such a commit that is reachable from $commit, you can stop the traversal because propagating the bit for B further down to its parents will not reach the $commit you are interested in.

So the termination condition for this a single Left (I'll use Left for $commit and Right for "all branches") case is "if a commit is already painted as reachable from $commit, do not propagate bits further down".

What does it mean to look for "branch --with $commit1 $commit2" (i.e. more than one in the Left set)? If we are trying to see which branches reach _both_ of these commits, then replace the ablve with "if a commit is already painted as reachable from both $commit{1,2}, then painting it with any branch bits is futile---its parents will never reach either $commit1 nor $commit2", so the additional termination condition will be "If left bits are full, then stop".

I do not know how you can optimize the traversal if you are trying to see which branches reach at least one of these commits, though.

Previous: Junio C HamanoNext: Junio C Hamano
Message 19 of 26 in “use merge-base for tag --contains”
  1. 0/8 use merge-base for tag --containsJeff King, Jun 25, 2014
  2. 1/8 tag: allow --sort with -nJeff King, Jun 25, 2014
  3. 2/8 tag: factor out decision to stream tagsJeff King, Jun 25, 2014
  4. 3/8 paint_down_to_common: use prio_queueJeff King, Jun 25, 2014
  5. Junio C HamanoJul 1, 2014
  6. Jeff KingJul 1, 2014
  7. 4/8 add functions for memory-efficient bitmapsJeff King, Jun 25, 2014
  8. Torsten BögershausenJun 26, 2014
  9. Jeff KingJun 26, 2014
  10. Eric SunshineJun 29, 2014
  11. Jeff KingJun 30, 2014
  12. Junio C HamanoJul 1, 2014
  13. Jeff KingJul 1, 2014
  14. 5/8 string-list: add pos to iterator callbackJeff King, Jun 25, 2014
  15. Junio C HamanoJul 1, 2014
  16. Jeff KingJul 1, 2014
  17. 6/8 commit: provide a fast multi-tip contains functionJeff King, Jun 25, 2014
  18. Junio C HamanoJun 26, 2014
  19. Junio C HamanoJun 26, 2014
  20. Junio C HamanoJun 26, 2014
  21. Junio C HamanoJul 1, 2014
  22. Junio C HamanoJul 1, 2014
  23. 7/8 tag: use commit_containsJeff King, Jun 25, 2014
  24. 8/8 perf: add tests for tag --containsJeff King, Jun 25, 2014
  25. Jeff KingJun 26, 2014
  26. Jeff KingJun 26, 2014

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.