@@ -374,6 +374,7 @@ test_expect_success PERL 'setup change in subdirectory' '
374374 echo master >sub/sub &&
375375 git add sub/sub &&
376376 git commit -m "added sub/sub" &&
377+ git tag v1 &&
377378 echo test >>file &&
378379 echo test >>sub/sub &&
379380 git add file sub/sub &&
@@ -409,12 +410,49 @@ run_dir_diff_test 'difftool --dir-diff ignores --prompt' '
409410 grep file output
410411'
411412
412- run_dir_diff_test ' difftool --dir-diff from subdirectory' '
413+ run_dir_diff_test ' difftool --dir-diff branch from subdirectory' '
413414 (
414415 cd sub &&
415416 git difftool --dir-diff $symlinks --extcmd ls branch >output &&
416- grep sub output &&
417- grep file output
417+ # "sub" must only exist in "right"
418+ # "file" and "file2" must be listed in both "left" and "right"
419+ test "1" = $(grep sub output | wc -l) &&
420+ test "2" = $(grep file"$" output | wc -l) &&
421+ test "2" = $(grep file2 output | wc -l)
422+ )
423+ '
424+
425+ run_dir_diff_test ' difftool --dir-diff v1 from subdirectory' '
426+ (
427+ cd sub &&
428+ git difftool --dir-diff $symlinks --extcmd ls v1 >output &&
429+ # "sub" and "file" exist in both v1 and HEAD.
430+ # "file2" is unchanged.
431+ test "2" = $(grep sub output | wc -l) &&
432+ test "2" = $(grep file output | wc -l) &&
433+ test "0" = $(grep file2 output | wc -l)
434+ )
435+ '
436+
437+ run_dir_diff_test ' difftool --dir-diff branch from subdirectory w/ pathspec' '
438+ (
439+ cd sub &&
440+ git difftool --dir-diff $symlinks --extcmd ls branch -- .>output &&
441+ # "sub" only exists in "right"
442+ # "file" and "file2" must not be listed
443+ test "1" = $(grep sub output | wc -l) &&
444+ test "0" = $(grep file output | wc -l)
445+ )
446+ '
447+
448+ run_dir_diff_test ' difftool --dir-diff v1 from subdirectory w/ pathspec' '
449+ (
450+ cd sub &&
451+ git difftool --dir-diff $symlinks --extcmd ls v1 -- .>output &&
452+ # "sub" exists in v1 and HEAD
453+ # "file" is filtered out by the pathspec
454+ test "2" = $(grep sub output | wc -l) &&
455+ test "0" = $(grep file output | wc -l)
418456 )
419457'
420458
0 commit comments