Re: [PATCH] Improve errors from 'git diff --no-index'.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio --

On Sun, May 22, 2011 at 8:14 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Anthony Foiani <anthony.foiani@xxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]