Skip to content

Commit d61027b

Browse files
Michael Spanggitster
authored andcommitted
Skip timestamp differences for diff --no-index
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>
1 parent bed5122 commit d61027b

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

diff-no-index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ void diff_no_index(struct rev_info *revs,
247247
else
248248
revs->diffopt.paths = argv + argc - 2;
249249
revs->diffopt.nr_paths = 2;
250+
revs->diffopt.skip_stat_unmatch = 1;
250251

251252
DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
252253
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);

t/t4013-diff-various.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ test_expect_success setup '
7474
for i in 1 2; do echo $i; done >>dir/sub &&
7575
git update-index file0 dir/sub &&
7676
77+
mkdir dir3 &&
78+
cp dir/sub dir3/sub &&
79+
test-chmtime +1 dir3/sub &&
80+
7781
git config log.showroot false &&
7882
git commit --amend &&
7983
git show-branch
@@ -262,6 +266,7 @@ diff --patch-with-raw -r initial..side
262266
diff --name-status dir2 dir
263267
diff --no-index --name-status dir2 dir
264268
diff --no-index --name-status -- dir2 dir
269+
diff --no-index dir dir3
265270
diff master master^ side
266271
EOF
267272

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$ git diff --no-index dir dir3
2+
$

0 commit comments

Comments
 (0)