diff: allow --no-patch as synonym for -s

This follows the usual convention of having a --no-foo option to negate --foo. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed Jul 16, 2013 at 10:05 UTC d09cd15d19de23aca532a85f6d27a71b2baceb3f
3 files changed +14 -1
Documentation/rev-list-options.txt
+1
@@ -839,5 +839,6 @@ options may be given. See linkgit:git-diff-files[1] for more options.
839 Show the tree objects in the diff output. This implies '-r'.
840
841 -s::
842 +--no-patch::
843 Suppress diff output.
844 endif::git-rev-list[]
diff.c
+1 -1
@@ -3540,7 +3540,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
3540 options->output_format |= DIFF_FORMAT_NAME;
3541 else if (!strcmp(arg, "--name-status"))
3542 options->output_format |= DIFF_FORMAT_NAME_STATUS;
3543 - else if (!strcmp(arg, "-s"))
3543 + else if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
3544 options->output_format |= DIFF_FORMAT_NO_OUTPUT;
3545 else if (!prefixcmp(arg, "--stat"))
3546 /* --stat, --stat-width, --stat-name-width, or --stat-count */
t/t4000-diff-format.sh
+12
@@ -59,4 +59,16 @@ test_expect_success 'validate git diff-files -p output.' '
59 compare_diff_patch expected actual
60 '
61
62 +test_expect_success 'git diff-files -s after editing work tree' '
63 + git diff-files -s >actual 2>err &&
64 + test_must_be_empty actual &&
65 + test_must_be_empty err
66 +'
67 +
68 +test_expect_success 'git diff-files --no-patch as synonym for -s' '
69 + git diff-files --no-patch >actual 2>err &&
70 + test_must_be_empty actual &&
71 + test_must_be_empty err
72 +'
73 +
74 test_done