git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Simon Ruderich <simon@ruderich.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: No "invalid option" message with git diff --cached --invalid-option
Date: Thu, 22 Jun 2017 10:13:06 -0400	[thread overview]
Message-ID: <20170622141305.lpso6r6yxejymvel@sigill.intra.peff.net> (raw)
In-Reply-To: <20170622124458.ilokr7acas2bzq4z@ruderich.org>

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

      reply	other threads:[~2017-06-22 14:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-22 12:44 No "invalid option" message with git diff --cached --invalid-option Simon Ruderich
2017-06-22 14:13 ` Jeff King [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

  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=20170622141305.lpso6r6yxejymvel@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=simon@ruderich.org \
    /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).