[PATCH 2/3] t7800: fix tests when difftool uses --no-symlinks

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

 



When 'git difftool --dir-diff' is using --no-symlinks (either explicitly
or implicitly because it's running on Windows), any working tree files
that have been copied to the temporary directory are copied back after
the difftool completes.  This includes untracked files in the working
tree.

During the tests, this means that the following sequence occurs:

1) the shell opens "output" to redirect the difftool output
2) difftool copies the empty "output" to the temporary directory
3) difftool runs "ls" which writes to "output"
4) difftool copies the empty "output" file back over the output of the
   command
5) the output files doesn't contain the expected output, causing the
   test to fail

Avoid this by writing the output into .git/ which will not be copied or
overwritten.

In the longer term, difftool probably needs to learn to warn the user
instead of overwrite any changes that have been made to the working tree
file.

Signed-off-by: John Keeping <john@xxxxxxxxxxxxx>
---
 t/t7800-difftool.sh | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index e694972..1eed439 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -319,29 +319,29 @@ test_expect_success PERL 'setup change in subdirectory' '
 '
 
 test_expect_success PERL 'difftool -d' '
-	git difftool -d --extcmd ls branch >output &&
-	grep sub output &&
-	grep file output
+	git difftool -d --extcmd ls branch >.git/output &&
+	grep sub .git/output &&
+	grep file .git/output
 '
 
 test_expect_success PERL 'difftool --dir-diff' '
-	git difftool --dir-diff --extcmd ls branch >output &&
-	grep sub output &&
-	grep file output
+	git difftool --dir-diff --extcmd ls branch >.git/output &&
+	grep sub .git/output &&
+	grep file .git/output
 '
 
 test_expect_success PERL 'difftool --dir-diff ignores --prompt' '
-	git difftool --dir-diff --prompt --extcmd ls branch >output &&
-	grep sub output &&
-	grep file output
+	git difftool --dir-diff --prompt --extcmd ls branch >.git/output &&
+	grep sub .git/output &&
+	grep file .git/output
 '
 
 test_expect_success PERL 'difftool --dir-diff from subdirectory' '
 	(
 		cd sub &&
-		git difftool --dir-diff --extcmd ls branch >output &&
-		grep sub output &&
-		grep file output
+		git difftool --dir-diff --extcmd ls branch >../.git/output &&
+		grep sub ../.git/output &&
+		grep file ../.git/output
 	)
 '
 
-- 
1.8.2.324.ga64ebd9

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