git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-mergetool--lib.sh: make check_unchanged return 1 on invalid read
@ 2011-09-19 20:03 Jay Soffian
  2011-09-19 20:37 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jay Soffian @ 2011-09-19 20:03 UTC (permalink / raw)
  To: git; +Cc: Jay Soffian, David Aguilar, Junio C Hamano

Else when the user hits ctrl-c at the "Was the merge successful?
[y/n]" prompt, mergetool goes into an infinite loop asking
for input.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
 git-mergetool--lib.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 8fc65d0400..0eb424484c 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -21,7 +21,11 @@ check_unchanged () {
 		do
 			echo "$MERGED seems unchanged."
 			printf "Was the merge successful? [y/n] "
-			read answer
+			if ! read answer
+			then
+				status=1
+				break
+			fi
 			case "$answer" in
 			y*|Y*) status=0; break ;;
 			n*|N*) status=1; break ;;
-- 
1.7.7.rc2.2.gf185

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-mergetool--lib.sh: make check_unchanged return 1 on invalid read
  2011-09-19 20:03 [PATCH] git-mergetool--lib.sh: make check_unchanged return 1 on invalid read Jay Soffian
@ 2011-09-19 20:37 ` Junio C Hamano
  2011-09-19 23:40   ` [PATCH] git-mergetool: check return value from read Jay Soffian
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2011-09-19 20:37 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git, David Aguilar

Jay Soffian <jaysoffian@gmail.com> writes:

> Else when the user hits ctrl-c at the "Was the merge successful?
> [y/n]" prompt, mergetool goes into an infinite loop asking
> for input.
>
> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>

We still seem to miss one "read" unchecked in resolve_symlink_merge(),
even with this patch.

>  git-mergetool--lib.sh |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
> index 8fc65d0400..0eb424484c 100644
> --- a/git-mergetool--lib.sh
> +++ b/git-mergetool--lib.sh
> @@ -21,7 +21,11 @@ check_unchanged () {
>  		do
>  			echo "$MERGED seems unchanged."
>  			printf "Was the merge successful? [y/n] "
> -			read answer
> +			if ! read answer
> +			then
> +				status=1
> +				break
> +			fi

I suspect that it would be more consistent with 6b44577 (mergetool: check
return value from read, 2011-07-01), which this patch is a follow-up to,
to do:

	read answer || return 1

here.

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] git-mergetool: check return value from read
  2011-09-19 20:37 ` Junio C Hamano
@ 2011-09-19 23:40   ` Jay Soffian
  2011-09-20  0:41     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jay Soffian @ 2011-09-19 23:40 UTC (permalink / raw)
  To: git; +Cc: Jay Soffian, David Aguilar, Junio C Hamano

Mostly fixed already by 6b44577 (mergetool: check return value
from read, 2011-07-01). Catch two uses it missed.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
On Mon, Sep 19, 2011 at 4:37 PM, Junio C Hamano <gitster@pobox.com> wrote:
> We still seem to miss one "read" unchecked in resolve_symlink_merge(),
> even with this patch.
> [...]
> I suspect that it would be more consistent with 6b44577 (mergetool: check
> return value from read, 2011-07-01), which this patch is a follow-up to,
> to do:
>
> 	read answer || return 1
>
> here.

Thanks, sorry I missed that.

 git-mergetool--lib.sh |    2 +-
 git-mergetool.sh      |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 8fc65d0400..ed630b208a 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -21,7 +21,7 @@ check_unchanged () {
 		do
 			echo "$MERGED seems unchanged."
 			printf "Was the merge successful? [y/n] "
-			read answer
+			read answer || return 1
 			case "$answer" in
 			y*|Y*) status=0; break ;;
 			n*|N*) status=1; break ;;
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 3c157bcd26..b6d463f0d0 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -72,7 +72,7 @@ describe_file () {
 resolve_symlink_merge () {
     while true; do
 	printf "Use (l)ocal or (r)emote, or (a)bort? "
-	read ans
+	read ans || return 1
 	case "$ans" in
 	    [lL]*)
 		git checkout-index -f --stage=2 -- "$MERGED"
-- 
1.7.7.rc2.2.gdf97720

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-mergetool: check return value from read
  2011-09-19 23:40   ` [PATCH] git-mergetool: check return value from read Jay Soffian
@ 2011-09-20  0:41     ` Junio C Hamano
  2011-09-20  1:20       ` Andrew Ardill
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2011-09-20  0:41 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git, David Aguilar

Jay Soffian <jaysoffian@gmail.com> writes:

>> I suspect that it would be more consistent with 6b44577 (mergetool: check
>> return value from read, 2011-07-01), which this patch is a follow-up to,
>> to do:
>>
>> 	read answer || return 1
>>
>> here.
>
> Thanks, sorry I missed that.

Thank _you_ for spotting these unchecked "read"s.  Will queue.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git-mergetool: check return value from read
  2011-09-20  0:41     ` Junio C Hamano
@ 2011-09-20  1:20       ` Andrew Ardill
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Ardill @ 2011-09-20  1:20 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jay Soffian, git, David Aguilar

On 20 September 2011 10:41, Junio C Hamano <gitster@pobox.com> wrote:
> Jay Soffian <jaysoffian@gmail.com> writes:
>
>>> I suspect that it would be more consistent with 6b44577 (mergetool: check
>>> return value from read, 2011-07-01), which this patch is a follow-up to,
>>> to do:
>>>
>>>      read answer || return 1
>>>
>>> here.
>>
>> Thanks, sorry I missed that.
>
> Thank _you_ for spotting these unchecked "read"s.  Will queue.
> --
> 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
>

I got hit by the ctrl+c bug while using mergetool just the other day.
Thanks for the fix :)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-09-20  1:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-19 20:03 [PATCH] git-mergetool--lib.sh: make check_unchanged return 1 on invalid read Jay Soffian
2011-09-19 20:37 ` Junio C Hamano
2011-09-19 23:40   ` [PATCH] git-mergetool: check return value from read Jay Soffian
2011-09-20  0:41     ` Junio C Hamano
2011-09-20  1:20       ` Andrew Ardill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).