git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Abort mergetool on read error from stdinput

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Dec 3, 2010, 09:05 UTC
Message-ID
<70B726FD-EC6A-47B2-9AB1-1CDA3B19358A@dewire.com>
In-Reply-To
<20101202063851.GA1407@burratino>
2 dec 2010 kl. 07:38 skrev Jonathan Nieder:
Show 27 quoted lines
> Hi Robin,
> 
> Robin Rosenberg wrote:
> 
>> infinite loop that is somewhat tricky to stop. Abort the script
>> if bash read fails.
>> 
>> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
> 
> That motivates half the change.
> 
>> --- 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
>> +			read answer < /dev/tty || exit 1
> 
> Why not
> 			read answer || exit 1
> 
> so tests can still run without blocking?  Aside from that, this looks
> like a good change; thanks.
> 
> What platform are you on?  ^C kills the entire process group here.
Here is a better version and motivation.
-- robin
>From 3aa3793a4d1dff940ca6b698a9c01a1fc9bdb9b3 Mon Sep 17 00:00:00 2001
From: Robin Rosenberg <robin.rosenberg@dewire.com>
Date: Fri, 3 Dec 2010 09:23:23 +0100
Subject: [PATCH] Abort mergetool on read error from stdinput

If the mergetool has not quit (by mistake like pressing Command-W instead of Command-Q) and the user pressed Ctrl-C in the shell that runs mergetool, bash goes into an infinite look, at least on Mac OS X. Ctrl-C kills the diff program but not the mergetool script.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 git-mergetool--lib.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 77d4aee..1d1413d 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
+			read answer || exit 1
 			case "$answer" in
 			y*|Y*) status=0; break ;;
 			n*|N*) status=1; break ;;
-- 
1.7.3.2.452.gb3012.dirty
Previous: Jonathan NiederNext: Jonathan Nieder
Message 3 of 5 in “Abort mergetool on read error from stdinput”
  1. Abort mergetool on read error from stdinputRobin Rosenberg, Dec 2, 2010
  2. Jonathan NiederDec 2, 2010
  3. Robin RosenbergDec 3, 2010
  4. Jonathan NiederDec 3, 2010
  5. Junio C HamanoDec 3, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.