Skip to content

Commit

Permalink
Skip timestamp differences for diff --no-index
Browse files Browse the repository at this point in the history
We display empty diffs for files whose timestamps have changed.
Usually, refreshing the index makes those empty diffs go away.
However, when not using the index they are not very useful and
there is no option to suppress them.

This forces on the skip_stat_unmatch option for diff --no-index,
suppressing any empty diffs. This option is also used for diffs
against the index when "diff.autorefreshindex" is set, but that
option does not apply to diff --no-index.

Signed-off-by: Michael Spang <mspang@uwaterloo.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Spang authored and Junio C Hamano committed Feb 18, 2009
1 parent bed5122 commit d61027b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions diff-no-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ void diff_no_index(struct rev_info *revs,
else
revs->diffopt.paths = argv + argc - 2;
revs->diffopt.nr_paths = 2;
revs->diffopt.skip_stat_unmatch = 1;

DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
Expand Down
5 changes: 5 additions & 0 deletions t/t4013-diff-various.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ test_expect_success setup '
for i in 1 2; do echo $i; done >>dir/sub &&
git update-index file0 dir/sub &&
mkdir dir3 &&
cp dir/sub dir3/sub &&
test-chmtime +1 dir3/sub &&
git config log.showroot false &&
git commit --amend &&
git show-branch
Expand Down Expand Up @@ -262,6 +266,7 @@ diff --patch-with-raw -r initial..side
diff --name-status dir2 dir
diff --no-index --name-status dir2 dir
diff --no-index --name-status -- dir2 dir
diff --no-index dir dir3
diff master master^ side
EOF

Expand Down
2 changes: 2 additions & 0 deletions t/t4013/diff.diff_--no-index_dir_dir3
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ git diff --no-index dir dir3
$

0 comments on commit d61027b

Please sign in to comment.