File tree Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -1351,6 +1351,9 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,
13511351 int len = eds -> len ;
13521352 unsigned flags = eds -> flags ;
13531353
1354+ if (o -> dry_run )
1355+ return ;
1356+
13541357 switch (s ) {
13551358 case DIFF_SYMBOL_NO_LF_EOF :
13561359 context = diff_get_color_opt (o , DIFF_CONTEXT );
@@ -4420,7 +4423,7 @@ static void run_external_diff(const struct external_diff *pgm,
44204423{
44214424 struct child_process cmd = CHILD_PROCESS_INIT ;
44224425 struct diff_queue_struct * q = & diff_queued_diff ;
4423- int quiet = !(o -> output_format & DIFF_FORMAT_PATCH );
4426+ int quiet = !(o -> output_format & DIFF_FORMAT_PATCH ) || o -> dry_run ;
44244427 int rc ;
44254428
44264429 /*
@@ -4615,7 +4618,8 @@ static void run_diff_cmd(const struct external_diff *pgm,
46154618 p -> status == DIFF_STATUS_RENAMED )
46164619 o -> found_changes = 1 ;
46174620 } else {
4618- fprintf (o -> file , "* Unmerged path %s\n" , name );
4621+ if (!o -> dry_run )
4622+ fprintf (o -> file , "* Unmerged path %s\n" , name );
46194623 o -> found_changes = 1 ;
46204624 }
46214625}
Original file line number Diff line number Diff line change @@ -661,6 +661,43 @@ test_expect_success 'diff -I<regex>: ignore matching file' '
661661 test_grep ! "file1" actual
662662'
663663
664+ test_expect_success ' diff -I<regex>: ignore all content changes' '
665+ test_when_finished "git rm -f file1 file2 file3" &&
666+ : >file1 &&
667+ git add file1 &&
668+ : >file2 &&
669+ git add file2 &&
670+ : >file3 &&
671+ git add file3 &&
672+
673+ rm -f file1 file2 &&
674+ mkdir file2 &&
675+ echo "A" >file3 &&
676+ A_hash=$(git hash-object -w file3) &&
677+ echo "B" >file3 &&
678+ B_hash=$(git hash-object -w file3) &&
679+ cat <<-EOF | git update-index --index-info &&
680+ 100644 $A_hash 1 file3
681+ 100644 $B_hash 2 file3
682+ EOF
683+
684+ test_diff_no_content_changes () {
685+ git diff $1 --ignore-blank-lines -I".*" >actual &&
686+ test_line_count = 3 actual &&
687+ test_grep "file1" actual &&
688+ test_grep "file2" actual &&
689+ test_grep "file3" actual &&
690+ test_grep ! "diff --git" actual
691+ } &&
692+ test_diff_no_content_changes "--raw" &&
693+ test_diff_no_content_changes "--name-only" &&
694+ test_diff_no_content_changes "--name-status" &&
695+
696+ : >actual &&
697+ test_must_fail git diff --quiet -I".*" >actual &&
698+ test_must_be_empty actual
699+ '
700+
664701# check_prefix <patch> <src> <dst>
665702# check only lines with paths to avoid dependency on exact oid/contents
666703check_prefix () {
You can’t perform that action at this time.
0 commit comments