Skip to contentSkip to conversation

git-mergetool--lib.sh: make check_unchanged return 1 on invalid read

PATCH In review Jay Soffian 3 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-mergetool--lib.sh: make check_unchanged return 1 on invalid read

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.

---
 git-mergetool--lib.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
git-mergetool--lib.sh +5 -1
index 8fc65d0400..0eb424484c 100644
@@ -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 ;;
Signature · 1 line
1.7.7.rc2.2.gf185
#1 lore raw
Quoted 5 lines · Jay Soffian

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.

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

Quoted 8 lines
 git-mergetool--lib.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
git-mergetool--lib.sh +0 -0
index 8fc65d0400..0eb424484c 100644

git-mergetool--lib.sh check_unchanged () { · line 28

Quoted 9 lines
git-mergetool--lib.sh +5 -1
@@ -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.

#2 lore raw

PATCH 1/1 git-mergetool: check return value from read

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

---

Quoted 10 lines · Junio C Hamano

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(-)
git-mergetool--lib.sh +1 -1
index 8fc65d0400..ed630b208a 100644
@@ -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 ;;
git-mergetool.sh +1 -1
index 3c157bcd26..b6d463f0d0 100755
@@ -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"
Signature · 1 line
1.7.7.rc2.2.gdf97720
#3 lore raw

Re: [PATCH] git-mergetool: check return value from read

Quoted 9 lines · Jay Soffian
Quoted 7 lines

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.

#4 lore raw

Re: [PATCH] git-mergetool: check return value from read

Quoted 10 lines · Junio C Hamano
Quoted 8 lines · Jay Soffian
Quoted 7 lines

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.

Quoted 8 lines
Quoted 1 line

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 [email protected]
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 :)