Skip to content

Commit af31471

Browse files
hashplinggitster
authored andcommitted
mergetool: Remove explicit references to /dev/tty
mergetool used /dev/tty to switch back to receiving input from the user via inside a block with a redirected stdin. This harms testability, so change mergetool to save its original stdin to an alternative fd in this block and restore it for those sub-commands that need the original stdin. Includes additional compatibility fix from Jonathan Nieder. Tested-by: Jonathan Nieder <[email protected]> Signed-off-by: Charles Bailey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 64fdc08 commit af31471

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

git-mergetool--lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ check_unchanged () {
3535
while true; do
3636
echo "$MERGED seems unchanged."
3737
printf "Was the merge successful? [y/n] "
38-
read answer < /dev/tty
38+
read answer
3939
case "$answer" in
4040
y*|Y*) status=0; break ;;
4141
n*|N*) status=1; break ;;

git-mergetool.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,21 @@ if test $# -eq 0 ; then
271271
echo "No files need merging"
272272
exit 0
273273
fi
274+
275+
# Save original stdin
276+
exec 3<&0
277+
274278
echo Merging the files: "$files"
275279
git ls-files -u |
276280
sed -e 's/^[^ ]* //' |
277281
sort -u |
278282
while IFS= read i
279283
do
280284
if test $last_status -ne 0; then
281-
prompt_after_failed_merge < /dev/tty || exit 1
285+
prompt_after_failed_merge <&3 || exit 1
282286
fi
283287
printf "\n"
284-
merge_file "$i" < /dev/tty > /dev/tty
288+
merge_file "$i" <&3
285289
last_status=$?
286290
if test $last_status -ne 0; then
287291
rollup_status=1

0 commit comments

Comments
 (0)