Re: [PATCH] mergetool: Remove explicit references to /dev/tty

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jonathan Nieder
Date: Friday, August 20, 2010 - 5:27 am

Charles Bailey wrote:


Sounds good.


Part of the run_merge_tool codepath.  The only place this is called
with TOOL_MODE=merge is by merge_file which has stdin redirected,
so this should be safe.  Good.


I would think this should work, but it doesn't feel idiomatic.  Why
not save stdin a little earlier, so the reader does not have to track
down whether it has been redirected?

The test quietly passes for me with dash but fails with ksh:

 /home/jrn/src/git4/git-mergetool: line 303: 3: cannot open [Bad file descriptor]

With the patch below on top, it passes with dash and ksh.
---
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 84edf7d..2e82522 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -275,10 +275,13 @@ files_to_merge() {
     fi
 }
 
 
 if test $# -eq 0 ; then
     cd_to_toplevel
 
+    # Save original stdin
+    exec 3<&0
+
     if test -e "$GIT_DIR/MERGE_RR"
     then
 	rerere=true
@@ -292,8 +294,7 @@ if test $# -eq 0 ; then
     printf "Merging:\n"
     printf "$files\n"
 
-    # Save original stdin to fd 3
-    files_to_merge 3<&0 |
+    files_to_merge |
     while IFS= read i
     do
 	if test $last_status -ne 0; then
-- 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Status of conflicted files resolved with rerere, Magnus Bäck, (Thu Aug 12, 2:28 pm)
Re: Status of conflicted files resolved with rerere, Avery Pennarun, (Thu Aug 12, 2:36 pm)
Re: Status of conflicted files resolved with rerere, Jay Soffian, (Fri Aug 13, 10:19 am)
Re: Status of conflicted files resolved with rerere, David Aguilar, (Sat Aug 14, 7:24 pm)
Re: Status of conflicted files resolved with rerere, Junio C Hamano, (Sat Aug 14, 11:59 pm)
Re: Status of conflicted files resolved with rerere, Magnus Bäck, (Sun Aug 15, 9:00 am)
[PATCH] mergetool: Skip autoresolved paths, David Aguilar, (Tue Aug 17, 2:22 am)
Re: [PATCH] mergetool: Skip autoresolved paths, Thomas Rast, (Thu Aug 19, 3:02 am)
Re: [PATCH] mergetool: Skip autoresolved paths, David Aguilar, (Thu Aug 19, 8:52 pm)
Re: [PATCH] mergetool: Skip autoresolved paths, Charles Bailey, (Fri Aug 20, 2:57 am)
Re: [PATCH] mergetool: Skip autoresolved paths, Jonathan Nieder, (Fri Aug 20, 3:09 am)
[PATCH] mergetool: Remove explicit references to /dev/tty, Charles Bailey, (Fri Aug 20, 4:17 am)
Re: [PATCH] mergetool: Remove explicit references to /dev/tty, Jonathan Nieder, (Fri Aug 20, 5:27 am)