t7800-difftool: don't accidentally match tmp dirs

In a bunch of test cases in 't7800-difftool.sh' we 'grep' for specific filenames in 'git difftool's output, and those test cases are prone to occasional failures because those filenames might be part of the name of difftool's temporary directory as well, e.g.: +git difftool --dir-diff --no-symlinks --extcmd ls v1 +grep sub output +test_line_count = 2 sub-output test_line_count: line count for sub-output != 2 /tmp/git-difftool.Ssubfq/left/: sub /tmp/git-difftool.Ssubfq/right/: sub error: last command exited with $?=1 not ok 50 - difftool --dir-diff v1 from subdirectory --no-symlinks Fix this by tightening the 'grep' patterns looking for those interesting filenames to match only lines where a filename stands on its own. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Jan 9, 2021 at 18:05 UTC e3f5da7e60060bacd2910b022e30449213e2370b
1 file changed +19 -19
t/t7800-difftool.sh
+19 -19
@@ -440,20 +440,20 @@ run_dir_diff_test () {
440
441 run_dir_diff_test 'difftool -d' '
442 git difftool -d $symlinks --extcmd ls branch >output &&
443 - grep sub output &&
444 - grep file output
443 + grep "^sub$" output &&
444 + grep "^file$" output
445 '
446
447 run_dir_diff_test 'difftool --dir-diff' '
448 git difftool --dir-diff $symlinks --extcmd ls branch >output &&
449 - grep sub output &&
450 - grep file output
449 + grep "^sub$" output &&
450 + grep "^file$" output
451 '
452
453 run_dir_diff_test 'difftool --dir-diff ignores --prompt' '
454 git difftool --dir-diff $symlinks --prompt --extcmd ls branch >output &&
455 - grep sub output &&
456 - grep file output
455 + grep "^sub$" output &&
456 + grep "^file$" output
457 '
458
459 run_dir_diff_test 'difftool --dir-diff branch from subdirectory' '
@@ -462,11 +462,11 @@ run_dir_diff_test 'difftool --dir-diff branch from subdirectory' '
462 git difftool --dir-diff $symlinks --extcmd ls branch >output &&
463 # "sub" must only exist in "right"
464 # "file" and "file2" must be listed in both "left" and "right"
465 - grep sub output >sub-output &&
465 + grep "^sub$" output >sub-output &&
466 test_line_count = 1 sub-output &&
467 - grep file"$" output >file-output &&
467 + grep "^file$" output >file-output &&
468 test_line_count = 2 file-output &&
469 - grep file2 output >file2-output &&
469 + grep "^file2$" output >file2-output &&
470 test_line_count = 2 file2-output
471 )
472 '
@@ -477,11 +477,11 @@ run_dir_diff_test 'difftool --dir-diff v1 from subdirectory' '
477 git difftool --dir-diff $symlinks --extcmd ls v1 >output &&
478 # "sub" and "file" exist in both v1 and HEAD.
479 # "file2" is unchanged.
480 - grep sub output >sub-output &&
480 + grep "^sub$" output >sub-output &&
481 test_line_count = 2 sub-output &&
482 - grep file output >file-output &&
482 + grep "^file$" output >file-output &&
483 test_line_count = 2 file-output &&
484 - ! grep file2 output
484 + ! grep "^file2$" output
485 )
486 '
487
@@ -491,9 +491,9 @@ run_dir_diff_test 'difftool --dir-diff branch from subdirectory w/ pathspec' '
491 git difftool --dir-diff $symlinks --extcmd ls branch -- .>output &&
492 # "sub" only exists in "right"
493 # "file" and "file2" must not be listed
494 - grep sub output >sub-output &&
494 + grep "^sub$" output >sub-output &&
495 test_line_count = 1 sub-output &&
496 - ! grep file output
496 + ! grep "^file$" output
497 )
498 '
499
@@ -503,9 +503,9 @@ run_dir_diff_test 'difftool --dir-diff v1 from subdirectory w/ pathspec' '
503 git difftool --dir-diff $symlinks --extcmd ls v1 -- .>output &&
504 # "sub" exists in v1 and HEAD
505 # "file" is filtered out by the pathspec
506 - grep sub output >sub-output &&
506 + grep "^sub$" output >sub-output &&
507 test_line_count = 2 sub-output &&
508 - ! grep file output
508 + ! grep "^file$" output
509 )
510 '
511
@@ -518,8 +518,8 @@ run_dir_diff_test 'difftool --dir-diff from subdirectory with GIT_DIR set' '
518 cd sub &&
519 git difftool --dir-diff $symlinks --extcmd ls \
520 branch -- sub >output &&
521 - grep sub output &&
522 - ! grep file output
521 + grep "^sub$" output &&
522 + ! grep "^file$" output
523 )
524 '
525
@@ -527,7 +527,7 @@ run_dir_diff_test 'difftool --dir-diff when worktree file is missing' '
527 test_when_finished git reset --hard &&
528 rm file2 &&
529 git difftool --dir-diff $symlinks --extcmd ls branch master >output &&
530 - grep file2 output
530 + grep "^file2$" output
531 '
532
533 run_dir_diff_test 'difftool --dir-diff with unmerged files' '