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

Re: [PATCH v4 0/4] Add --no-ahead-behind to status

From
Jeff King <peff@peff.net>
Date
Jan 10, 2018, 07:41 UTC
Message-ID
<20180110074159.GA16315@sigill.intra.peff.net>
In-Reply-To
<nycvar.QRO.7.76.6.1801091407480.37@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz>
On Tue, Jan 09, 2018 at 02:15:47PM +0100, Johannes Schindelin wrote:
> > I like this direction a lot. I had hoped we could say "100+ commits
> > ahead",
> 
> How about "100+ commits apart" instead?
Yeah, that is probably more accurate for the general case.
Show 12 quoted lines
> > but I don't think we can do so accurately without generation numbers.
> 
> Even with generation numbers, it is not possible to say whether two given
> commits reflect diverging branches or have an ancestor-descendant
> relationship (or in graph speak: whether they are comparable).
> 
> It could potentially make it possible to cut off the commit traversal, but
> I do not even see how that would be possible.
> 
> The only thing you could say for sure is that two different commits with
> the same generation number are for sure "uncomparable", i.e. reflect
> diverging branches.

I think sometimes we can say more. E.g., imagine we have two commits, A and B, with generation numbers N and N+1000. We walk back 100 commits deep from B and end up at a commit around N+900. We know that there are at least 100 commits in B that are not in A (the 100 we walked, which we know cannot be ancestors of A because of their generation numbers). That's true even if there is no ancestry relationship between the two commits at all.

But we cannot say in that case how many (if any) commits are in A but not B. So we can say "100+ commits ahead, unknown behind" (or if the two generation numbers are reversed, we can say "unknown ahead, 100+ commits behind).

In the more general case, we could actually walk _past_ generation N, and end up at N-25 or similar. There we can't say anything intelligent about the commits with generations <= N. But we could say something like "there are 75 commits in B that cannot be in A" (note that it's probably _not_ actually 75; it's however many we walked until we crossed N).

So that was what I was getting at in the earlier mail. We can sometimes give a partial answer. But I think giving that partial answer is likely to be more confusing than useful to a user, because there are a lot of caveats about how much we know for a given situation.

And I think from what you wrote below that you probably agree with that (that we can make a few claims, but not enough to really be useful).

-Peff
Previous: Jeff King
Message 16 of 16 in “Add --no-ahead-behind to status”
  1. 0/4 Add --no-ahead-behind to statusJeff Hostetler, Jan 8, 2018
  2. 1/4 stat_tracking_info: return +1 when branches not equalJeff Hostetler, Jan 8, 2018
  3. 2/4 status: add --[no-]ahead-behind to status and commit for V2 format.Jeff Hostetler, Jan 8, 2018
  4. 3/4 status: update short status to respect --no-ahead-behindJeff Hostetler, Jan 8, 2018
  5. 4/4 status: support --no-ahead-behind in long formatJeff Hostetler, Jan 8, 2018
  6. Ben PeartJan 8, 2018
  7. Jeff HostetlerJan 8, 2018
  8. Jeff KingJan 9, 2018
  9. Johannes SchindelinJan 9, 2018
  10. Derrick StoleeJan 9, 2018
  11. Jeff HostetlerJan 9, 2018
  12. Johannes SchindelinJan 9, 2018
  13. Jeff KingJan 10, 2018
  14. Junio C HamanoJan 10, 2018
  15. Jeff KingJan 11, 2018
  16. Jeff KingJan 10, 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.