Skip to content

Commit 8c33b4c

Browse files
jrngitster
authored andcommitted
tests: Fix race condition in t7006-pager
Pagers that do not consume their input are dangerous: for example, $ GIT_PAGER=: git log $ echo $? 141 $ The only reason these tests were able to work before was that 'git log' would write to the pipe (and not fill it) before the pager had time to terminate and close the pipe. Fix it by using a program that consumes its input, namely wc (as suggested by Johannes). Reported-by: Johannes Sixt <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2d3ca21 commit 8c33b4c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

t/t7006-pager.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ rm -f default_pager_used
137137
test_expect_success SIMPLEPAGER 'default pager is used by default' '
138138
cat > $less <<-EOF &&
139139
#!$SHELL_PATH
140-
: > default_pager_used
140+
wc > default_pager_used
141141
EOF
142142
chmod +x $less &&
143143
PATH=.:$PATH test_terminal git log &&
@@ -148,7 +148,7 @@ unset GIT_PAGER
148148
git config --unset core.pager
149149
rm -f PAGER_used
150150
test_expect_success TTY 'PAGER overrides default pager' '
151-
PAGER=": > PAGER_used" &&
151+
PAGER="wc > PAGER_used" &&
152152
export PAGER &&
153153
test_terminal git log &&
154154
test -e PAGER_used
@@ -157,17 +157,17 @@ test_expect_success TTY 'PAGER overrides default pager' '
157157
unset GIT_PAGER
158158
rm -f core.pager_used
159159
test_expect_success TTY 'core.pager overrides PAGER' '
160-
PAGER=: &&
160+
PAGER=wc &&
161161
export PAGER &&
162-
git config core.pager ": > core.pager_used" &&
162+
git config core.pager "wc > core.pager_used" &&
163163
test_terminal git log &&
164164
test -e core.pager_used
165165
'
166166

167167
rm -f GIT_PAGER_used
168168
test_expect_success TTY 'GIT_PAGER overrides core.pager' '
169-
git config core.pager : &&
170-
GIT_PAGER=": > GIT_PAGER_used" &&
169+
git config core.pager wc &&
170+
GIT_PAGER="wc > GIT_PAGER_used" &&
171171
export GIT_PAGER &&
172172
test_terminal git log &&
173173
test -e GIT_PAGER_used

0 commit comments

Comments
 (0)