Skip to content

Commit e3f5da7

Browse files
szedergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 47ae905 commit e3f5da7

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

t/t7800-difftool.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -440,20 +440,20 @@ run_dir_diff_test () {
440440

441441
run_dir_diff_test 'difftool -d' '
442442
git difftool -d $symlinks --extcmd ls branch >output &&
443-
grep sub output &&
444-
grep file output
443+
grep "^sub$" output &&
444+
grep "^file$" output
445445
'
446446

447447
run_dir_diff_test 'difftool --dir-diff' '
448448
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
451451
'
452452

453453
run_dir_diff_test 'difftool --dir-diff ignores --prompt' '
454454
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
457457
'
458458

459459
run_dir_diff_test 'difftool --dir-diff branch from subdirectory' '
@@ -462,11 +462,11 @@ run_dir_diff_test 'difftool --dir-diff branch from subdirectory' '
462462
git difftool --dir-diff $symlinks --extcmd ls branch >output &&
463463
# "sub" must only exist in "right"
464464
# "file" and "file2" must be listed in both "left" and "right"
465-
grep sub output >sub-output &&
465+
grep "^sub$" output >sub-output &&
466466
test_line_count = 1 sub-output &&
467-
grep file"$" output >file-output &&
467+
grep "^file$" output >file-output &&
468468
test_line_count = 2 file-output &&
469-
grep file2 output >file2-output &&
469+
grep "^file2$" output >file2-output &&
470470
test_line_count = 2 file2-output
471471
)
472472
'
@@ -477,11 +477,11 @@ run_dir_diff_test 'difftool --dir-diff v1 from subdirectory' '
477477
git difftool --dir-diff $symlinks --extcmd ls v1 >output &&
478478
# "sub" and "file" exist in both v1 and HEAD.
479479
# "file2" is unchanged.
480-
grep sub output >sub-output &&
480+
grep "^sub$" output >sub-output &&
481481
test_line_count = 2 sub-output &&
482-
grep file output >file-output &&
482+
grep "^file$" output >file-output &&
483483
test_line_count = 2 file-output &&
484-
! grep file2 output
484+
! grep "^file2$" output
485485
)
486486
'
487487

@@ -491,9 +491,9 @@ run_dir_diff_test 'difftool --dir-diff branch from subdirectory w/ pathspec' '
491491
git difftool --dir-diff $symlinks --extcmd ls branch -- .>output &&
492492
# "sub" only exists in "right"
493493
# "file" and "file2" must not be listed
494-
grep sub output >sub-output &&
494+
grep "^sub$" output >sub-output &&
495495
test_line_count = 1 sub-output &&
496-
! grep file output
496+
! grep "^file$" output
497497
)
498498
'
499499

@@ -503,9 +503,9 @@ run_dir_diff_test 'difftool --dir-diff v1 from subdirectory w/ pathspec' '
503503
git difftool --dir-diff $symlinks --extcmd ls v1 -- .>output &&
504504
# "sub" exists in v1 and HEAD
505505
# "file" is filtered out by the pathspec
506-
grep sub output >sub-output &&
506+
grep "^sub$" output >sub-output &&
507507
test_line_count = 2 sub-output &&
508-
! grep file output
508+
! grep "^file$" output
509509
)
510510
'
511511

@@ -518,16 +518,16 @@ run_dir_diff_test 'difftool --dir-diff from subdirectory with GIT_DIR set' '
518518
cd sub &&
519519
git difftool --dir-diff $symlinks --extcmd ls \
520520
branch -- sub >output &&
521-
grep sub output &&
522-
! grep file output
521+
grep "^sub$" output &&
522+
! grep "^file$" output
523523
)
524524
'
525525

526526
run_dir_diff_test 'difftool --dir-diff when worktree file is missing' '
527527
test_when_finished git reset --hard &&
528528
rm file2 &&
529529
git difftool --dir-diff $symlinks --extcmd ls branch master >output &&
530-
grep file2 output
530+
grep "^file2$" output
531531
'
532532

533533
run_dir_diff_test 'difftool --dir-diff with unmerged files' '

0 commit comments

Comments
 (0)