From af3147147f39274bd0d47faca196f84c4e9ec68d Mon Sep 17 00:00:00 2001 From: Charles Bailey Date: Fri, 20 Aug 2010 16:25:09 +0100 Subject: 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 Signed-off-by: Charles Bailey Signed-off-by: Junio C Hamano --- git-mergetool.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'git-mergetool.sh') diff --git a/git-mergetool.sh b/git-mergetool.sh index b52a7410bc..e7fa67bd9c 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -271,6 +271,10 @@ if test $# -eq 0 ; then echo "No files need merging" exit 0 fi + + # Save original stdin + exec 3<&0 + echo Merging the files: "$files" git ls-files -u | sed -e 's/^[^ ]* //' | @@ -278,10 +282,10 @@ if test $# -eq 0 ; then while IFS= read i do if test $last_status -ne 0; then - prompt_after_failed_merge < /dev/tty || exit 1 + prompt_after_failed_merge <&3 || exit 1 fi printf "\n" - merge_file "$i" < /dev/tty > /dev/tty + merge_file "$i" <&3 last_status=$? if test $last_status -ne 0; then rollup_status=1 -- cgit v1.2.3