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

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

From
Jay Soffian <jaysoffian@gmail.com>
Date
Sep 19, 2011, 23:40 UTC
Message-ID
<1316475652-35188-1-git-send-email-jaysoffian@gmail.com>
In-Reply-To
<7vaaa09skn.fsf@alter.siamese.dyndns.org>

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:
Show 10 quoted lines
> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 5 in “git-mergetool--lib.sh: make check_unchanged return 1 on invalid read”
  1. git-mergetool--lib.sh: make check_unchanged return 1 on invalid readJay Soffian, Sep 19, 2011
  2. Junio C HamanoSep 19, 2011
  3. git-mergetool: check return value from readJay Soffian, Sep 19, 2011
  4. Junio C HamanoSep 20, 2011
  5. Andrew ArdillSep 20, 2011

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.