{"thread":{"id":"46231","subject":"No \"invalid option\" message with git diff --cached --invalid-option","startedAt":"2017-06-22T12:50:21Z","lastAt":"2017-06-22T14:13:14Z","messageCount":2,"participants":["Simon Ruderich","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"322925","messageId":"20170622124458.ilokr7acas2bzq4z@ruderich.org","threadId":"46231","inReplyTo":null,"subject":"No \"invalid option\" message with git diff --cached --invalid-option","fromName":"Simon Ruderich","fromEmail":"simon@ruderich.org","sentAt":"2017-06-22T12:44:58Z","receivedAt":"2017-06-22T12:50:21Z","isPatch":false,"sender":{"key":"simon@ruderich.org","avatar":"https://avatars.githubusercontent.com/u/390994?v=4"},"body":"Hello,\n\nI'm using Git 2.13.1 (from the Debian sid repository) and noticed\nthe following issue when upgrading.\n\n    $ git diff --compaction-heuristic\n    error: invalid option: --compaction-heuristic\n\n    $ git diff --cached --compaction-heuristic\n    usage: git diff [<options>] [<commit> [<commit>]] [--] [<path>...]\n\nI know that --compaction-heuristic is no longer supported but I\nwas using it an alias and was confused that I got no proper error\nmessage warning me which option was wrong.\n\nIt seems to happen for any invalid option which is used in\ncombination with --cached or --staged.\n\nRegards\nSimon\n-- \n+ privacy is necessary\n+ using gnupg http://gnupg.org\n+ public key id: 0x92FEFDB7E44C32F9\n"},{"id":"322930","messageId":"20170622141305.lpso6r6yxejymvel@sigill.intra.peff.net","threadId":"46231","inReplyTo":"20170622124458.ilokr7acas2bzq4z@ruderich.org","subject":"Re: No \"invalid option\" message with git diff --cached --invalid-option","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-06-22T14:13:06Z","receivedAt":"2017-06-22T14:13:14Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jun 22, 2017 at 02:44:58PM +0200, Simon Ruderich wrote:\n\n> I'm using Git 2.13.1 (from the Debian sid repository) and noticed\n> the following issue when upgrading.\n> \n>     $ git diff --compaction-heuristic\n>     error: invalid option: --compaction-heuristic\n> \n>     $ git diff --cached --compaction-heuristic\n>     usage: git diff [<options>] [<commit> [<commit>]] [--] [<path>...]\n> \n> I know that --compaction-heuristic is no longer supported but I\n> was using it an alias and was confused that I got no proper error\n> message warning me which option was wrong.\n> \n> It seems to happen for any invalid option which is used in\n> combination with --cached or --staged.\n\nThe diff command splits off into several sub-functions based on whether\nwe're doing an index-to-file diff, an index-to-tree diff, etc. It looks\nlike builtin_diff_files() and builtin_diff_index() just handle this case\ndifferently. Probably both should issue an error() mentioning the\nunknown option _and_ call usage().\n\nI started on a patch, but maybe this would be good micro-project for\nsomebody wanting to get their feet wet with contributing to Git. Bonus\npoints for checking the other functions (builtin_diff_blobs,\nbuiltin_diff_tree, builtin_diff_b_f) and making sure they all give\nappropriate messages when showing the usage string.\n\n-Peff\n"}]}