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

Re: [PATCH v2 1/5] core.aheadbehind: add new config setting

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 2, 2018, 22:17 UTC
Message-ID
<20180102221717.GD131371@aiede.mtv.corp.google.com>
In-Reply-To
<2a5eb18a-d1b4-da2d-c2c8-5798d8627617@jeffhostetler.com>
Hi,
Jeff Hostetler wrote:
> On 12/21/2017 3:43 PM, Jonathan Nieder wrote:
Show 12 quoted lines
>> I also wonder if there's a way to achieve the same benefit without
>> having it be configurable.  E.g. if a branch is way behind, couldn't
>> we terminate the walk early to get the same bounded cost per branch
>> without requiring configuration?
>
> I created a config setting because we don't want to force users to
> type "git status --no-ahead-behind" on every interactive command to
> get the benefit of it.  I guess we could ask them to alias it, if we
> don't want a config setting.
>
> Also, I didn't want to change the time-tested behavior that users see,
> so I didn't want to change the algorithm in any way -- just not call it.

I'm not too worried about people relying on the time-tested behavior in this case. It's a convenience feature for human users --- any scripts looking for this information would be likely to use a more convenient command like rev-list.

The one exception is "git status --porcelain=v2". For that command, scripts are likely to expect to be able to parse the "+<ahead> -<behind>" line. Alas, guarding it with a config doesn't help such scripts --- they still need to be able to cope with the new behavior.

git-status(1) says:
	Parsers should ignore headers that they don't recognize.

so introducing a new line like "# branch.matchesupstream (true | false)" like you did seems reasonable enough. I *suspect* it should be okay to omit the "# branch.ab" line as long as the script didn't explicitly pass --ahead-behind but that depends on whether any scripts in the wild were relying on the "# branch.ab" line being present.

> Would it make more sense to name this something like "status.aheadBehindLimit"
> where 0 would mean no limit and match existing behavior and a positive
> number be the number of commits we are allowed to search before giving up.
Sounds good to me.

Thanks, Jonathan

Previous: Jeff HostetlerNext: Jeff Hostetler
Message 14 of 20 in “Add --no-ahead-behind to status”
  1. 0/5 Add --no-ahead-behind to statusJeff Hostetler, Dec 21, 2017
  2. 1/5 core.aheadbehind: add new config settingJeff Hostetler, Dec 21, 2017
  3. Igor DjordjevicDec 21, 2017
  4. Jonathan NiederDec 21, 2017
  5. Junio C HamanoDec 22, 2017
  6. Jeff KingDec 24, 2017
  7. Junio C HamanoDec 27, 2017
  8. Jeff KingJan 4, 2018
  9. Lars SchneiderApr 3, 2018
  10. Ævar Arnfjörð BjarmasonApr 3, 2018
  11. Derrick StoleeApr 3, 2018
  12. Jeff HostetlerApr 3, 2018
  13. Jeff HostetlerJan 2, 2018
  14. Jonathan NiederJan 2, 2018
  15. 3/5 status: add --[no-]ahead-behind to porcelain V2 outputJeff Hostetler, Dec 21, 2017
  16. Jonathan NiederDec 21, 2017
  17. 4/5 status: update short status to use --no-ahead-behindJeff Hostetler, Dec 21, 2017
  18. 5/5 status: support --no-ahead-behind in long formatJeff Hostetler, Dec 21, 2017
  19. 2/5 stat_tracking_info: return +1 when branches are not equalJeff Hostetler, Dec 21, 2017
  20. Jonathan NiederDec 21, 2017

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.