aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-04-03 09:34:09 -0700
committerJunio C Hamano <gitster@pobox.com>2013-04-03 09:34:09 -0700
commit288e6ff5a64331e5da1dd9d978938b44d50f5be9 (patch)
tree9839dd834ffd0070a8493a5e78205d5b805ec21b /t
parentf30366b27a91dbc18328bccf3067cdfad4f0cfbc (diff)
parente01afdb74b395e63a6ee8feb8cb3a6ee470e2085 (diff)
downloadgit-288e6ff5a64331e5da1dd9d978938b44d50f5be9.tar.gz
git-288e6ff5a64331e5da1dd9d978938b44d50f5be9.tar.xz
Merge branch 'jk/difftool-no-overwrite-on-copyback'
Try to be careful when difftool backend allows the user to write into the temporary files being shown *and* the user makes changes to the working tree at the same time. One of the changes has to be lost in such a case, but at least tell the user what he did. * jk/difftool-no-overwrite-on-copyback: t7800: run --dir-diff tests with and without symlinks t7800: fix tests when difftool uses --no-symlinks t7800: don't hide grep output difftool: don't overwrite modified files t7800: move '--symlinks' specific test to the end
Diffstat (limited to 't')
-rwxr-xr-xt/t7800-difftool.sh105
1 files changed, 68 insertions, 37 deletions
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index c6d6b1c99..a6bd99eaf 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -23,16 +23,6 @@ prompt_given ()
test "$prompt" = "Launch 'test-tool' [Y/n]: branch"
}
-stdin_contains ()
-{
- grep >/dev/null "$1"
-}
-
-stdin_doesnot_contain ()
-{
- ! stdin_contains "$1"
-}
-
# Create a file on master and change it on branch
test_expect_success PERL 'setup' '
echo master >file &&
@@ -296,24 +286,24 @@ test_expect_success PERL 'setup with 2 files different' '
test_expect_success PERL 'say no to the first file' '
(echo n && echo) >input &&
git difftool -x cat branch <input >output &&
- stdin_contains m2 <output &&
- stdin_contains br2 <output &&
- stdin_doesnot_contain master <output &&
- stdin_doesnot_contain branch <output
+ grep m2 output &&
+ grep br2 output &&
+ ! grep master output &&
+ ! grep branch output
'
test_expect_success PERL 'say no to the second file' '
(echo && echo n) >input &&
git difftool -x cat branch <input >output &&
- stdin_contains master <output &&
- stdin_contains branch <output &&
- stdin_doesnot_contain m2 <output &&
- stdin_doesnot_contain br2 <output
+ grep master output &&
+ grep branch output &&
+ ! grep m2 output &&
+ ! grep br2 output
'
test_expect_success PERL 'difftool --tool-help' '
git difftool --tool-help >output &&
- stdin_contains tool <output
+ grep tool output
'
test_expect_success PERL 'setup change in subdirectory' '
@@ -324,20 +314,46 @@ test_expect_success PERL 'setup change in subdirectory' '
git commit -m "added sub/sub" &&
echo test >>file &&
echo test >>sub/sub &&
- git add . &&
+ git add file sub/sub &&
git commit -m "modified both"
'
-test_expect_success PERL 'difftool -d' '
- git difftool -d --extcmd ls branch >output &&
- stdin_contains sub <output &&
- stdin_contains file <output
+run_dir_diff_test () {
+ test_expect_success PERL "$1 --no-symlinks" "
+ symlinks=--no-symlinks &&
+ $2
+ "
+ test_expect_success PERL,SYMLINKS "$1 --symlinks" "
+ symlinks=--symlinks &&
+ $2
+ "
+}
+
+run_dir_diff_test 'difftool -d' '
+ git difftool -d $symlinks --extcmd ls branch >output &&
+ grep sub output &&
+ grep file output
+'
+
+run_dir_diff_test 'difftool --dir-diff' '
+ git difftool --dir-diff $symlinks --extcmd ls branch >output &&
+ grep sub output &&
+ grep file output
'
-test_expect_success PERL 'difftool --dir-diff' '
- git difftool --dir-diff --extcmd ls branch >output &&
- stdin_contains sub <output &&
- stdin_contains file <output
+run_dir_diff_test 'difftool --dir-diff ignores --prompt' '
+ git difftool --dir-diff $symlinks --prompt --extcmd ls branch >output &&
+ grep sub output &&
+ grep file output
+'
+
+run_dir_diff_test 'difftool --dir-diff from subdirectory' '
+ (
+ cd sub &&
+ git difftool --dir-diff $symlinks --extcmd ls branch >output &&
+ grep sub output &&
+ grep file output
+ )
'
write_script .git/CHECK_SYMLINKS <<\EOF
@@ -362,18 +378,33 @@ test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstage
test_cmp actual expect
'
-test_expect_success PERL 'difftool --dir-diff ignores --prompt' '
- git difftool --dir-diff --prompt --extcmd ls branch >output &&
- stdin_contains sub <output &&
- stdin_contains file <output
+write_script modify-file <<\EOF
+echo "new content" >file
+EOF
+
+test_expect_success PERL 'difftool --no-symlinks does not overwrite working tree file ' '
+ echo "orig content" >file &&
+ git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-file" branch &&
+ echo "new content" >expect &&
+ test_cmp expect file
'
-test_expect_success PERL 'difftool --dir-diff from subdirectory' '
+write_script modify-both-files <<\EOF
+echo "wt content" >file &&
+echo "tmp content" >"$2/file" &&
+echo "$2" >tmpdir
+EOF
+
+test_expect_success PERL 'difftool --no-symlinks detects conflict ' '
(
- cd sub &&
- git difftool --dir-diff --extcmd ls branch >output &&
- stdin_contains sub <output &&
- stdin_contains file <output
+ TMPDIR=$TRASH_DIRECTORY &&
+ export TMPDIR &&
+ echo "orig content" >file &&
+ test_must_fail git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-both-files" branch &&
+ echo "wt content" >expect &&
+ test_cmp expect file &&
+ echo "tmp content" >expect &&
+ test_cmp expect "$(cat tmpdir)/file"
)
'