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

Re: [RFC] revision: Add --sticky-default option

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 18, 2018, 06:59 UTC
Message-ID
<xmqqlg6vu4dw.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20181018064845.GB23537@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 10 quoted lines
> Just to play devil's advocate, how about this:
>
>   git log --branches=jk/* --not origin/master
>
> Right now that shows nothing if there are no matching branches. But I
> think under the proposed behavior, it would start showing HEAD, which
> seems counter-intuitive.
>
> Or are we going to count any positive selector as a positive ref, even
> if it matches nothing? 

That sounds like an intuitive behaviour of the command, but I may change my mind when I look at other examples.

When viewing that "--branches=jk/*" example in isolation, yes, these positive selectors that could produce positive revs should defeat the --default, especially when it is built-in (like "log"). When given by the user, I am not sure. With something like this:

	git rev-list --default=HEAD --branches=jk/* ^master

clearly the user anticipates that jk/* may or may not produce any positive refs; otherwise there is no point specifying the default.

But anyway...
Show 12 quoted lines
> I could buy that, though it means that the
> command above is subtly different from one or both of:
>
>   branches() {
>     git for-each-ref --format='%(refname)' refs/heads/jk/*
>   }
>
>   # is --stdin a selector, too?
>   branches | git log --stdin --not origin/master
>
>   # here we have no idea that the user did a query and must show HEAD
>   git log $(branches) --not origin/master

OK, scrap that---just as I predicted a few minutes ago, I now think that "do we have a positive selector that can produce zero or more result?" is an ill-defined question X-<.

Thanks for a doze of sanity.
Previous: Jeff KingNext: Andreas Gruenbacher
Message 9 of 12 in “[RFC] revision: Add --sticky-default option”
  1. Andreas GruenbacherOct 16, 2018
  2. Jeff KingOct 17, 2018
  3. Matthew DeVoreOct 17, 2018
  4. Jeff KingOct 17, 2018
  5. Andreas GruenbacherOct 17, 2018
  6. Jeff KingOct 17, 2018
  7. Junio C HamanoOct 18, 2018
  8. Jeff KingOct 18, 2018
  9. Junio C HamanoOct 18, 2018
  10. Andreas GruenbacherOct 18, 2018
  11. Junio C HamanoOct 18, 2018
  12. Andreas GruenbacherOct 18, 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.