]> granicus.if.org Git - git/commitdiff
diff: allow --no-patch as synonym for -s
authorMatthieu Moy <Matthieu.Moy@imag.fr>
Tue, 16 Jul 2013 08:05:36 +0000 (10:05 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Jul 2013 00:50:56 +0000 (17:50 -0700)
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>
Documentation/rev-list-options.txt
diff.c
t/t4000-diff-format.sh

index 3bdbf5e856b68692745a91304d80b09186d487b4..1acef370d17707bb1058378ca19a7b81472fc8f9 100644 (file)
@@ -839,5 +839,6 @@ options may be given. See linkgit:git-diff-files[1] for more options.
        Show the tree objects in the diff output. This implies '-r'.
 
 -s::
+--no-patch::
        Suppress diff output.
 endif::git-rev-list[]
diff --git a/diff.c b/diff.c
index f0b3e7cfe34a99c0e5fea85fcd00ec54e9b578d8..cc41d88c985d6b0b2b1b3fbeebb332b4a1307df4 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -3540,7 +3540,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
                options->output_format |= DIFF_FORMAT_NAME;
        else if (!strcmp(arg, "--name-status"))
                options->output_format |= DIFF_FORMAT_NAME_STATUS;
-       else if (!strcmp(arg, "-s"))
+       else if (!strcmp(arg, "-s") || !strcmp(arg, "--no-patch"))
                options->output_format |= DIFF_FORMAT_NO_OUTPUT;
        else if (!prefixcmp(arg, "--stat"))
                /* --stat, --stat-width, --stat-name-width, or --stat-count */
index 2b5dffc3c4d4bdd3f36a18f819875fe43ce0f91e..3b9a9ae682f2025b755c23f20937f44d40bb3680 100755 (executable)
@@ -59,4 +59,16 @@ test_expect_success 'validate git diff-files -p output.' '
        compare_diff_patch expected actual
 '
 
+test_expect_success 'git diff-files -s after editing work tree' '
+       git diff-files -s >actual 2>err &&
+       test_must_be_empty actual &&
+       test_must_be_empty err
+'
+
+test_expect_success 'git diff-files --no-patch as synonym for -s' '
+       git diff-files --no-patch >actual 2>err &&
+       test_must_be_empty actual &&
+       test_must_be_empty err
+'
+
 test_done