git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Robert P. J. Day" <rpjday@crashcourse.ca>
Cc: Git Mailing list <git@vger.kernel.org>
Subject: Re: [PATCH v3] doc: tweak "man gitcli" for clarity
Date: Fri, 24 Nov 2017 15:23:04 +0900	[thread overview]
Message-ID: <xmqqo9nsnqk7.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqd148p8v4.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Fri, 24 Nov 2017 14:02:23 +0900")

Junio C Hamano <gitster@pobox.com> writes:

>> - * Without disambiguating `--`, Git makes a reasonable guess, but errors
>> -   out and asking you to disambiguate when ambiguous.  E.g. if you have a
>> -   file called HEAD in your work tree, `git diff HEAD` is ambiguous, and
>> + * In cases where a Git command is truly ambiguous, Git will error out
>> +   and ask you to disambiguate the command.  E.g. if you have a file
>> +   called HEAD in your work tree, `git diff HEAD` is ambiguous, and
>>     you have to say either `git diff HEAD --` or `git diff -- HEAD` to
>>     disambiguate.
>>  ...
>
> The above "truly" is misleading by giving the information the other
> way around.  We ask to disambiguate when we cannot readily say the
> command line is *not* unambiguous.  That is different from asking
> when we know it is truly ambiguous.
>
> Also see <xmqq7eugqykq.fsf@gitster.mtv.corp.google.com> if you want
> to know more.

So, here is my attempt (other than "the original reads clear enough
to me, so I am not sure what's there to improve"):

    When the command line does not have the disambiguating `--`, Git
    needs to find where the revisions end and paths begin.  In order
    to make sure it does not guess incorrectly, Git errors out when
    it cannot cheaply determine that there is no ambiguity, and asks
    you to disambiguate with `--`.  If you have a file whose name is
    HEAD, "git diff HEAD" gets an error for this reason; you need to
    say "git diff -- HEAD" or "git diff HEAD --" to disambiguate.

    Also, if you do not have a file whose name is Nakefile and it is
    not a branch or tag name, "git log Nakefile" is flagged as an
    error.  If you know there used to be a file called Nakefile but
    not in the current working tree, "git log -- Nakefile" is how
    you tell Git that you did not make a typo and you mean to find
    commits that touch the path.

I briefly considered the following as a more technically correct
description for "cheaply determine", but I am not sure if we want to
go down to that level of detail:

    ... when it cannot determine that every argument before one
    point on the command line names a revision and does not have a
    file with that name in the working tree, and every argument
    after that point does have a file with that name and cannot be
    interpreted as a valid revision.

>>  When writing a script that is expected to handle random user-input, it is
>>  a good practice to make it explicit which arguments are which by placing
>> -disambiguating `--` at appropriate places.
>> +a disambiguating `--` at appropriate places.

I forgot to mention in my earlier message, but this part of the
patch is obviously good ;-)

  reply	other threads:[~2017-11-24  6:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22 12:03 [PATCH v3] doc: tweak "man gitcli" for clarity Robert P. J. Day
2017-11-24  5:02 ` Junio C Hamano
2017-11-24  6:23   ` Junio C Hamano [this message]
2017-11-24 10:39   ` Robert P. J. Day

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqo9nsnqk7.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=rpjday@crashcourse.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).