[PATCH] t7005: fix subdirectory-filter test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The test would not fail if the filtering failed to do anything, since
in

  test -z "$(git diff HEAD directorymoved:newsubdir)"'

'directorymoved:newsubdir' is not valid, so git-diff fails without
printing anything on stdout.  But then the exit status of git-diff is
lost, whereas test -z "" succeeds.

Use 'git diff --exit-code' instead, which does the right thing and has
the added bonus of showing the differences if there are any.

Signed-off-by: Thomas Rast <trast@xxxxxxxxxxxxxxx>
---

Tomas Carnecky wrote:
> Now the test fails. And with the other patch applied on top of it, the
> test passes again.

Ok.  Here's a slightly nicer solution, let's add this on top of the
earlier patch.

 t/t7003-filter-branch.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index e90da6d..84c2612 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -148,7 +148,8 @@ test_expect_success 'use index-filter to move into a subdirectory' '
 	          GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
 			git update-index --index-info &&
 		  mv \"\$GIT_INDEX_FILE.new\" \"\$GIT_INDEX_FILE\"" directorymoved &&
-	test -z "$(git diff HEAD directorymoved:newsubdir)"'
+	git diff --exit-code HEAD directorymoved:newsubdir
+'
 
 test_expect_success 'stops when msg filter fails' '
 	old=$(git rev-parse HEAD) &&
-- 
1.7.2.1.342.g676a4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]