Skip to content

Commit

Permalink
diff: allow --no-patch as synonym for -s
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Matthieu Moy authored and Junio C Hamano committed Jul 18, 2013
1 parent 8ade9b1 commit d09cd15
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Documentation/rev-list-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
2 changes: 1 addition & 1 deletion diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
12 changes: 12 additions & 0 deletions t/t4000-diff-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d09cd15

Please sign in to comment.