git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* No "invalid option" message with git diff --cached --invalid-option
@ 2017-06-22 12:44 Simon Ruderich
  2017-06-22 14:13 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Ruderich @ 2017-06-22 12:44 UTC (permalink / raw)
  To: Git Mailing List

Hello,

I'm using Git 2.13.1 (from the Debian sid repository) and noticed
the following issue when upgrading.

    $ git diff --compaction-heuristic
    error: invalid option: --compaction-heuristic

    $ git diff --cached --compaction-heuristic
    usage: git diff [<options>] [<commit> [<commit>]] [--] [<path>...]

I know that --compaction-heuristic is no longer supported but I
was using it an alias and was confused that I got no proper error
message warning me which option was wrong.

It seems to happen for any invalid option which is used in
combination with --cached or --staged.

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: No "invalid option" message with git diff --cached --invalid-option
  2017-06-22 12:44 No "invalid option" message with git diff --cached --invalid-option Simon Ruderich
@ 2017-06-22 14:13 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2017-06-22 14:13 UTC (permalink / raw)
  To: Simon Ruderich; +Cc: Git Mailing List

On Thu, Jun 22, 2017 at 02:44:58PM +0200, Simon Ruderich wrote:

> I'm using Git 2.13.1 (from the Debian sid repository) and noticed
> the following issue when upgrading.
> 
>     $ git diff --compaction-heuristic
>     error: invalid option: --compaction-heuristic
> 
>     $ git diff --cached --compaction-heuristic
>     usage: git diff [<options>] [<commit> [<commit>]] [--] [<path>...]
> 
> I know that --compaction-heuristic is no longer supported but I
> was using it an alias and was confused that I got no proper error
> message warning me which option was wrong.
> 
> It seems to happen for any invalid option which is used in
> combination with --cached or --staged.

The diff command splits off into several sub-functions based on whether
we're doing an index-to-file diff, an index-to-tree diff, etc. It looks
like builtin_diff_files() and builtin_diff_index() just handle this case
differently. Probably both should issue an error() mentioning the
unknown option _and_ call usage().

I started on a patch, but maybe this would be good micro-project for
somebody wanting to get their feet wet with contributing to Git. Bonus
points for checking the other functions (builtin_diff_blobs,
builtin_diff_tree, builtin_diff_b_f) and making sure they all give
appropriate messages when showing the usage string.

-Peff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-22 14:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-22 12:44 No "invalid option" message with git diff --cached --invalid-option Simon Ruderich
2017-06-22 14:13 ` Jeff King

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).