{"thread":{"id":"25923","subject":"[PATCH] Abort mergetool on read error from stdinput","startedAt":"2010-12-02T06:28:21Z","lastAt":"2010-12-03T19:45:22Z","messageCount":5,"participants":["Robin Rosenberg","Jonathan Nieder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"157087","messageId":"1291271301-12511-1-git-send-email-robin.rosenberg@dewire.com","threadId":"25923","inReplyTo":null,"subject":"[PATCH] Abort mergetool on read error from stdinput","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2010-12-02T06:28:21Z","receivedAt":"2010-12-02T06:28:21Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"If you press e.g Ctrl-C the interactive merge goes into an\ninfinite loop that is somewhat tricky to stop. Abort the script\nif bash read fails.\n\nSigned-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n---\n git-mergetool--lib.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nindex 77d4aee..2fc2886 100644\n--- a/git-mergetool--lib.sh\n+++ b/git-mergetool--lib.sh\n@@ -35,7 +35,7 @@ check_unchanged () {\n \t\twhile true; do\n \t\t\techo \"$MERGED seems unchanged.\"\n \t\t\tprintf \"Was the merge successful? [y/n] \"\n-\t\t\tread answer\n+\t\t\tread answer < /dev/tty || exit 1\n \t\t\tcase \"$answer\" in\n \t\t\ty*|Y*) status=0; break ;;\n \t\t\tn*|N*) status=1; break ;;\n-- \n1.7.2.3\n"},{"id":"157088","messageId":"20101202063851.GA1407@burratino","threadId":"25923","inReplyTo":"1291271301-12511-1-git-send-email-robin.rosenberg@dewire.com","subject":"Re: [PATCH] Abort mergetool on read error from stdinput","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-12-02T06:38:51Z","receivedAt":"2010-12-02T06:38:51Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Robin,\n\nRobin Rosenberg wrote:\n\n> infinite loop that is somewhat tricky to stop. Abort the script\n> if bash read fails.\n>\n> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n\nThat motivates half the change.\n\n> --- a/git-mergetool--lib.sh\n> +++ b/git-mergetool--lib.sh\n> @@ -35,7 +35,7 @@ check_unchanged () {\n>  \t\twhile true; do\n>  \t\t\techo \"$MERGED seems unchanged.\"\n>  \t\t\tprintf \"Was the merge successful? [y/n] \"\n> -\t\t\tread answer\n> +\t\t\tread answer < /dev/tty || exit 1\n\nWhy not\n\t\t\tread answer || exit 1\n\nso tests can still run without blocking?  Aside from that, this looks\nlike a good change; thanks.\n\nWhat platform are you on?  ^C kills the entire process group here.\n"},{"id":"157187","messageId":"70B726FD-EC6A-47B2-9AB1-1CDA3B19358A@dewire.com","threadId":"25923","inReplyTo":"20101202063851.GA1407@burratino","subject":"Re: [PATCH] Abort mergetool on read error from stdinput","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2010-12-03T09:05:01Z","receivedAt":"2010-12-03T09:05:01Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"\n2 dec 2010 kl. 07:38 skrev Jonathan Nieder:\n\n> Hi Robin,\n> \n> Robin Rosenberg wrote:\n> \n>> infinite loop that is somewhat tricky to stop. Abort the script\n>> if bash read fails.\n>> \n>> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n> \n> That motivates half the change.\n> \n>> --- a/git-mergetool--lib.sh\n>> +++ b/git-mergetool--lib.sh\n>> @@ -35,7 +35,7 @@ check_unchanged () {\n>> \t\twhile true; do\n>> \t\t\techo \"$MERGED seems unchanged.\"\n>> \t\t\tprintf \"Was the merge successful? [y/n] \"\n>> -\t\t\tread answer\n>> +\t\t\tread answer < /dev/tty || exit 1\n> \n> Why not\n> \t\t\tread answer || exit 1\n> \n> so tests can still run without blocking?  Aside from that, this looks\n> like a good change; thanks.\n> \n> What platform are you on?  ^C kills the entire process group here.\n\nHere is a better version and motivation.\n\n-- robin\n\n>From 3aa3793a4d1dff940ca6b698a9c01a1fc9bdb9b3 Mon Sep 17 00:00:00 2001\nFrom: Robin Rosenberg <robin.rosenberg@dewire.com>\nDate: Fri, 3 Dec 2010 09:23:23 +0100\nSubject: [PATCH] Abort mergetool on read error from stdinput\n\nIf the mergetool has not quit (by mistake like pressing\nCommand-W instead of Command-Q) and the user pressed Ctrl-C\nin the shell that runs mergetool, bash goes into an infinite\nlook, at least on Mac OS X. Ctrl-C kills the diff program\nbut not the mergetool script.\n\nSigned-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n---\n git-mergetool--lib.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nindex 77d4aee..1d1413d 100644\n--- a/git-mergetool--lib.sh\n+++ b/git-mergetool--lib.sh\n@@ -35,7 +35,7 @@ check_unchanged () {\n \t\twhile true; do\n \t\t\techo \"$MERGED seems unchanged.\"\n \t\t\tprintf \"Was the merge successful? [y/n] \"\n-\t\t\tread answer\n+\t\t\tread answer || exit 1\n \t\t\tcase \"$answer\" in\n \t\t\ty*|Y*) status=0; break ;;\n \t\t\tn*|N*) status=1; break ;;\n-- \n1.7.3.2.452.gb3012.dirty\n"},{"id":"157189","messageId":"20101203091409.GG18202@burratino","threadId":"25923","inReplyTo":"70B726FD-EC6A-47B2-9AB1-1CDA3B19358A@dewire.com","subject":"Re: [PATCH] Abort mergetool on read error from stdinput","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-12-03T09:14:09Z","receivedAt":"2010-12-03T09:14:09Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Robin Rosenberg wrote:\n\n> Subject: [PATCH] Abort mergetool on read error from stdinput\n> \n> If the mergetool has not quit (by mistake like pressing\n> Command-W instead of Command-Q) and the user pressed Ctrl-C\n> in the shell that runs mergetool, bash goes into an infinite\n> look, at least on Mac OS X. Ctrl-C kills the diff program\n> but not the mergetool script.\n> \n> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n> ---\n>  git-mergetool--lib.sh |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n> \n> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\n> index 77d4aee..1d1413d 100644\n> --- a/git-mergetool--lib.sh\n> +++ b/git-mergetool--lib.sh\n> @@ -35,7 +35,7 @@ check_unchanged () {\n>  \t\twhile true; do\n>  \t\t\techo \"$MERGED seems unchanged.\"\n>  \t\t\tprintf \"Was the merge successful? [y/n] \"\n> -\t\t\tread answer\n> +\t\t\tread answer || exit 1\n>  \t\t\tcase \"$answer\" in\n>  \t\t\ty*|Y*) status=0; break ;;\n>  \t\t\tn*|N*) status=1; break ;;\n\n> Here is a better version and motivation.\n\nThanks.  For what it's worth,\nAcked-by: Jonathan Nieder <jrnieder@gmail.com>\n"},{"id":"157249","messageId":"7vwrnqod2l.fsf@alter.siamese.dyndns.org","threadId":"25923","inReplyTo":"70B726FD-EC6A-47B2-9AB1-1CDA3B19358A@dewire.com","subject":"Re: [PATCH] Abort mergetool on read error from stdinput","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-03T19:45:22Z","receivedAt":"2010-12-03T19:45:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robin Rosenberg <robin.rosenberg@dewire.com> writes:\n\n>> What platform are you on?  ^C kills the entire process group here.\n>\n> Here is a better version and motivation.\n>\n> -- robin\n>\n> From 3aa3793a4d1dff940ca6b698a9c01a1fc9bdb9b3 Mon Sep 17 00:00:00 2001\n> From: Robin Rosenberg <robin.rosenberg@dewire.com>\n> Date: Fri, 3 Dec 2010 09:23:23 +0100\n> Subject: [PATCH] Abort mergetool on read error from stdinput\n>\n> If the mergetool has not quit (by mistake like pressing\n> Command-W instead of Command-Q) and the user pressed Ctrl-C\n> in the shell that runs mergetool, bash goes into an infinite\n> look, at least on Mac OS X. Ctrl-C kills the diff program\n> but not the mergetool script.\n\nInteresting.  Perhaps the way the script is spawned need to be improved so\nthat \\C-c will do the right thing to avoid this infinite \"loop\"?\n\nIs \"exit 1\" the best thing to do here?  Doesn't the caller of this\nfunction (or the caller of that caller) want to perform some clean-up\naction depending on the answer that comes back from it?\n\nWhat I am wondering is if it would futureproof us better to set $status to\nan appropriate value and break out of the loop, pretending that the end\nuser gave a reasonable answer (probably \"n\" but I am just guessing) to\n\"read answer\", instead of dying.\n\n> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n> ---\n>  git-mergetool--lib.sh |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n>\n> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\n> index 77d4aee..1d1413d 100644\n> --- a/git-mergetool--lib.sh\n> +++ b/git-mergetool--lib.sh\n> @@ -35,7 +35,7 @@ check_unchanged () {\n>  \t\twhile true; do\n>  \t\t\techo \"$MERGED seems unchanged.\"\n>  \t\t\tprintf \"Was the merge successful? [y/n] \"\n> -\t\t\tread answer\n> +\t\t\tread answer || exit 1\n>  \t\t\tcase \"$answer\" in\n>  \t\t\ty*|Y*) status=0; break ;;\n>  \t\t\tn*|N*) status=1; break ;;\n> -- \n> 1.7.3.2.452.gb3012.dirty\n"}]}