diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-02-08 13:36:03 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-08 13:36:03 -0800 |
commit | a83c2d2972b7821e45192df08142d27ebc51da48 (patch) | |
tree | 06647fcd34262da86bee65a45477fecccd579f22 | |
parent | t7800: simplify basic usage test (diff) | |
parent | difftool: fix dir-diff index creation when in a subdirectory (diff) | |
download | tgif-a83c2d2972b7821e45192df08142d27ebc51da48.tar.xz |
Merge branch 'da/difftool-dir-diff-fix' into da/t7800-cleanup
* da/difftool-dir-diff-fix:
difftool: fix dir-diff index creation when in a subdirectory
-rwxr-xr-x | contrib/examples/git-difftool.perl | 4 | ||||
-rwxr-xr-x | t/t7800-difftool.sh | 44 |
2 files changed, 45 insertions, 3 deletions
diff --git a/contrib/examples/git-difftool.perl b/contrib/examples/git-difftool.perl index a5790d03a0..959822d5f3 100755 --- a/contrib/examples/git-difftool.perl +++ b/contrib/examples/git-difftool.perl @@ -182,6 +182,10 @@ EOF } } + # Go to the root of the worktree so that the left index files + # are properly setup -- the index is toplevel-relative. + chdir($workdir); + # Setup temp directories my $tmpdir = tempdir('git-difftool.XXXXX', CLEANUP => 0, TMPDIR => 1); my $ldir = "$tmpdir/left"; diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 3d728e296d..97bae54d83 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -386,6 +386,7 @@ test_expect_success 'setup change in subdirectory' ' echo master >sub/sub && git add sub/sub && git commit -m "added sub/sub" && + git tag v1 && echo test >>file && echo test >>sub/sub && git add file sub/sub && @@ -421,12 +422,49 @@ run_dir_diff_test 'difftool --dir-diff ignores --prompt' ' grep file output ' -run_dir_diff_test 'difftool --dir-diff from subdirectory' ' +run_dir_diff_test 'difftool --dir-diff branch from subdirectory' ' ( cd sub && git difftool --dir-diff $symlinks --extcmd ls branch >output && - grep sub output && - grep file output + # "sub" must only exist in "right" + # "file" and "file2" must be listed in both "left" and "right" + test "1" = $(grep sub output | wc -l) && + test "2" = $(grep file"$" output | wc -l) && + test "2" = $(grep file2 output | wc -l) + ) +' + +run_dir_diff_test 'difftool --dir-diff v1 from subdirectory' ' + ( + cd sub && + git difftool --dir-diff $symlinks --extcmd ls v1 >output && + # "sub" and "file" exist in both v1 and HEAD. + # "file2" is unchanged. + test "2" = $(grep sub output | wc -l) && + test "2" = $(grep file output | wc -l) && + test "0" = $(grep file2 output | wc -l) + ) +' + +run_dir_diff_test 'difftool --dir-diff branch from subdirectory w/ pathspec' ' + ( + cd sub && + git difftool --dir-diff $symlinks --extcmd ls branch -- .>output && + # "sub" only exists in "right" + # "file" and "file2" must not be listed + test "1" = $(grep sub output | wc -l) && + test "0" = $(grep file output | wc -l) + ) +' + +run_dir_diff_test 'difftool --dir-diff v1 from subdirectory w/ pathspec' ' + ( + cd sub && + git difftool --dir-diff $symlinks --extcmd ls v1 -- .>output && + # "sub" exists in v1 and HEAD + # "file" is filtered out by the pathspec + test "2" = $(grep sub output | wc -l) && + test "0" = $(grep file output | wc -l) ) ' |