git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Skip timestamp differences for diff --no-index
@ 2009-02-18  6:48 Michael Spang
  2009-02-18 10:53 ` Johannes Schindelin
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Spang @ 2009-02-18  6:48 UTC (permalink / raw)
  To: Junio C Hamano, git

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>
---
 diff-no-index.c                       |    1 +
 t/t4013-diff-various.sh               |    5 +++++
 t/t4013/diff.diff_--no-index_dir_dir3 |    2 ++
 3 files changed, 8 insertions(+), 0 deletions(-)
 create mode 100644 t/t4013/diff.diff_--no-index_dir_dir3

diff --git a/diff-no-index.c b/diff-no-index.c
index 0dbd9da..0a14268 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -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);
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index aba5320..9c70902 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -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
@@ -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
 
diff --git a/t/t4013/diff.diff_--no-index_dir_dir3 b/t/t4013/diff.diff_--no-index_dir_dir3
new file mode 100644
index 0000000..2142c2b
--- /dev/null
+++ b/t/t4013/diff.diff_--no-index_dir_dir3
@@ -0,0 +1,2 @@
+$ git diff --no-index dir dir3
+$
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Skip timestamp differences for diff --no-index
  2009-02-18  6:48 [PATCH] Skip timestamp differences for diff --no-index Michael Spang
@ 2009-02-18 10:53 ` Johannes Schindelin
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Schindelin @ 2009-02-18 10:53 UTC (permalink / raw)
  To: Michael Spang; +Cc: Junio C Hamano, git

Hi,

On Wed, 18 Feb 2009, Michael Spang wrote:

> 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>
> ---

Nice!  And very nicely written patch!

Thanks,
Dscho

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-18 10:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-18  6:48 [PATCH] Skip timestamp differences for diff --no-index Michael Spang
2009-02-18 10:53 ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).