summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Bailey <charles@hashpling.org>2010-08-20 15:25:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-08-20 21:09:04 (GMT)
commitaf3147147f39274bd0d47faca196f84c4e9ec68d (patch)
tree020b1f727a6786ce01dfeacf5c86e83acabc4f5d
parent64fdc08dac6694d1e754580e7acb82dfa4988bb9 (diff)
downloadgit-af3147147f39274bd0d47faca196f84c4e9ec68d.zip
git-af3147147f39274bd0d47faca196f84c4e9ec68d.tar.gz
git-af3147147f39274bd0d47faca196f84c4e9ec68d.tar.bz2
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 <jrnieder@gmail.com> Signed-off-by: Charles Bailey <charles@hashpling.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--git-mergetool--lib.sh2
-rwxr-xr-xgit-mergetool.sh8
2 files changed, 7 insertions, 3 deletions
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 51dd0d6..b5e1943 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -35,7 +35,7 @@ check_unchanged () {
while true; do
echo "$MERGED seems unchanged."
printf "Was the merge successful? [y/n] "
- read answer < /dev/tty
+ read answer
case "$answer" in
y*|Y*) status=0; break ;;
n*|N*) status=1; break ;;
diff --git a/git-mergetool.sh b/git-mergetool.sh
index b52a741..e7fa67b 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