[PATCH v2 7/7] t4045: test 'diff --relative' for real

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

 



The existing tests only checked how well -relative=<dir> work,
without testing --relative (without any value).

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 t/t4045-diff-relative.sh | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/t/t4045-diff-relative.sh b/t/t4045-diff-relative.sh
index fefd2f3f81..815cdd7295 100755
--- a/t/t4045-diff-relative.sh
+++ b/t/t4045-diff-relative.sh
@@ -25,7 +25,10 @@ check_diff () {
 	+other content
 	EOF
 	test_expect_success "-p $*" "
-		git diff -p $* HEAD^ >actual &&
+		(
+			test -z "$in_there" || cd "$in_there"
+			git diff -p $* HEAD^
+		) >actual &&
 		test_cmp expected actual
 	"
 }
@@ -38,7 +41,10 @@ check_numstat () {
 	EOF
 	test_expect_success "--numstat $*" "
 		echo '1	0	$expect' >expected &&
-		git diff --numstat $* HEAD^ >actual &&
+		(
+			test -z "$in_there" || cd "$in_there"
+			git diff --numstat $* HEAD^
+		) >actual &&
 		test_cmp expected actual
 	"
 }
@@ -51,7 +57,10 @@ check_stat () {
 	 1 file changed, 1 insertion(+)
 	EOF
 	test_expect_success "--stat $*" "
-		git diff --stat $* HEAD^ >actual &&
+		(
+			test -z "$in_there" || cd "$in_there"
+			git diff --stat $* HEAD^
+		) >actual &&
 		test_i18ncmp expected actual
 	"
 }
@@ -63,15 +72,22 @@ check_raw () {
 	:000000 100644 0000000000000000000000000000000000000000 25c05ef3639d2d270e7fe765a67668f098092bc5 A	$expect
 	EOF
 	test_expect_success "--raw $*" "
-		git diff --no-abbrev --raw $* HEAD^ >actual &&
+		(
+			test -z "$in_there" || cd "$in_there"
+			git diff --no-abbrev --raw $* HEAD^ >actual
+		) &&
 		test_cmp expected actual
 	"
 }
 
 for type in diff numstat stat raw
 do
+	in_there=
 	check_$type file2 --relative=subdir/
 	check_$type file2 --relative=subdir
+	in_there=subdir
+	check_$type file2 --relative
+	in_there=
 	check_$type dir/file2 --relative=sub
 done
 
-- 
2.15.1-480-gbc5668f98a




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

  Powered by Linux