All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Foiani <anthony.foiani@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Improve errors from 'git diff --no-index'.
Date: Sun, 22 May 2011 20:35:40 -0600	[thread overview]
Message-ID: <BANLkTinKpSP5oEms914TWD7Tsjab1B87QQ@mail.gmail.com> (raw)
In-Reply-To: <7vlixyw4cx.fsf@alter.siamese.dyndns.org>

Junio --

On Sun, May 22, 2011 at 8:14 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Anthony Foiani <anthony.foiani@gmail.com> writes:
>
>> I accidentally tried to use "git diff" when I wasn't within a git
>> repository, only to be confused by getting a usage message with no
>> particular error output.
>
> I do not understand this at all.
>
>    $ cd /
>    $ git diff
>    usage: git diff [--no-index] <path> <path>
>
> What's unclear about it?

It's hard for me to explain right now, as I just spent a few hours
figuring out exactly what "git diff" assumed would happen.  And now
that I have done that study, I would not need anything beyond the
original error message, either.

But when I screwed up earlier today, I was somewhat taken aback by the
fact that I kept on getting the same usage message with no indication
of what the heck I was doing wrong:

$ git diff -b main.c
usage: git diff [--no-index] <path> <path>
$ git diff --cached -b main.c
usage: git diff [--no-index] <path> <path>
$ git diff -b HEAD -- main.c
usage: git diff [--no-index] <path> <path>
$ git diff -b -- main.c
usage: git diff [--no-index] <path> <path>

It would have saved me a chunk of time to have one of my diagnostics
(in this case, "not in a git repo") to knock some sense into me
earlier.

*shrug* Toss it in the bit-bucket if you like, but the work's already
been done. And I happen to find the new code more readable than the
previous triple-negative and de Morgan's-expanded conditionals, but
that's of course personal taste.

For that matter, the existing code was already doing many of these
checks, but not communicating the results back in any way other than
presenting a usage string. I apparently interpreted that as "you're
calling me wrong", not "you're using me wrong".

There might be a bug even in the previous code, though: there's an odd
early exit from 'path_outside_repo' for absolute pathnames, but I got
lost in the multiple negations and could never quite convince myself
of its correctness (or lack thereof).

Either way, thanks for all your work on git!

Best regards,
Tony

  parent reply	other threads:[~2011-05-23  2:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-22 19:17 [PATCH] Improve errors from 'git diff --no-index' Anthony Foiani
     [not found] ` <7vlixyw4cx.fsf@alter.siamese.dyndns.org>
2011-05-23  2:35   ` Anthony Foiani [this message]
2011-05-23  3:18     ` Junio C Hamano
2011-05-23  4:05       ` Anthony Foiani
2011-05-23 19:22         ` Junio C Hamano
2011-05-23 20:50           ` Jeff King
2011-05-23 21:24           ` Anthony Foiani

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=BANLkTinKpSP5oEms914TWD7Tsjab1B87QQ@mail.gmail.com \
    --to=anthony.foiani@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.