Re: is there a stylistic preference for a trailing "--" on a command?
- From
Jeff King <peff@peff.net>
- Date
- Nov 11, 2017, 15:39 UTC
- Message-ID
- <20171111151907.owrbpnn35aepj4ha@sigill.intra.peff.net>
- In-Reply-To
- <CAGZ79kavxFA_wBzcSbR8LT4uZGkdv4c07ZMfE4TK0tkooMGg6Q@mail.gmail.com>
On Fri, Nov 10, 2017 at 10:12:39AM -0800, Stefan Beller wrote:
Show 18 quoted lines
> On Fri, Nov 10, 2017 at 5:57 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote: > > > > just noticed these examples in "man git-bisect": > > > > EXAMPLES > > $ git bisect start HEAD v1.2 -- # HEAD is bad, v1.2 is good > > ... > > $ git bisect start HEAD origin -- # HEAD is bad, origin is good > > ... > > $ git bisect start HEAD HEAD~10 -- # culprit is among the last 10 > > > > is there some rationale or stylistic significance to those trailing > > "--" on those commands? i assume they have no effect, just curious as > > to why they're there. > > By having the -- there, it is clear that the strings are ref specs and not files > of such a name. (Who would want to store a file named HEAD~10 in their > repo?)
Just to be explicit, that makes it not just clear to the user but clear to Git. Without a "--" there heuristics that kick in. The first section of the "gitcli" manpage talks about this, though I don't know that we explicitly document the heuristics anywhere (and I think that is intentional -- we promise only to try to do what you meant, and scripts that want exact behavior should use a disambiguating "--").
-Peff