git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [RFH/PATCH] blame: tighten command line parser
Date: Mon, 5 Feb 2018 23:42:53 -0500	[thread overview]
Message-ID: <CAPig+cTFSWJX3FyXA6JJPhd1TT9eS0QOtm_R2qB6SX8W60ZWtA@mail.gmail.com> (raw)
In-Reply-To: <xmqqmv0n80ue.fsf@gitster-ct.c.googlers.com>

On Mon, Feb 5, 2018 at 6:37 PM, Junio C Hamano <gitster@pobox.com> wrote:
> The command line parser of "git blame" is prepared to take an
> ancient odd argument order "blame <path> <rev>" in addition to the
> usual "blame [<rev>] <path>".  It has at least two negative
> ramifications:
>
>  - In order to tell these two apart, it checks if the last command
>    line argument names a path in the working tree, using
>    file_exists().  However, "blame <rev> <path>" is a request to
>    explalin each and every line in the contents of <path> stored in

s/explalin/explain/

>    revision <rev> and does not need to have a working tree version
>    of the file.  A check with file_exists() is simply wrong.
>
>  - To coerce that mistaken file_exists() check to work, the code
>    calls setup_work_tree() before doing so, because the path it has
>    is relative to the top-level of the project tree.  However,
>    "blame <rev> <path>" MUST be usable even in a bare repository,
>    and there is no reason for letting setup_work_tree() to complain

s/to complain/complain/

>    and die with "This operation must be run in a work tree".
>
> To correct the former, switch to check if the last token is a
> revision (and if so, parse arguments using "blame <path> <rev>"
> rule).  Correct the latter by getting rid of setup_work_tree() and
> file_exists() check--the only case the call to this function matters
> is when we are running "blame <path>" (i.e. no starting revision and
> asking to blame the working tree file at <path>, digging through the
> HEAD revision), but there is a call in setup_scoreboard() just
> before it calls fake_working_tree_commit().
>
> Also attempt to give a bit more sensible error message when "blame
> XYZ" is given and XYZ cannot be a path.
>
>    side note: I am not happy with the "only one arg, which is a rev,
>    given in a bare repository" condition to give the new error
>    message, but this should be a good starting point.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

      reply	other threads:[~2018-02-06  4:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05 23:37 [RFH/PATCH] blame: tighten command line parser Junio C Hamano
2018-02-06  4:42 ` Eric Sunshine [this message]

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

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

  git send-email \
    --in-reply-to=CAPig+cTFSWJX3FyXA6JJPhd1TT9eS0QOtm_R2qB6SX8W60ZWtA@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
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 NNTP newsgroup(s).