From 57a39690b936c003662b6710241732b980e58790 Mon Sep 17 00:00:00 2001
From: Junio C Hamano <junkio@cox.net>
Date: Mon, 10 Jul 2006 03:34:34 -0700
Subject: [PATCH] fetch/clone: check return status from ls-remote

Some callers of ls-remote did not check its return status.
---
 git-clone.sh |  4 ++--
 git-fetch.sh | 11 +++++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/git-clone.sh b/git-clone.sh
index 0368803883..a92b22a13d 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -266,7 +266,7 @@ yes,yes)
 	    echo "$repo/objects" >> "$GIT_DIR/objects/info/alternates"
 	    ;;
 	esac
-	git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD"
+	git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1
 	;;
 *)
 	case "$repo" in
@@ -296,7 +296,7 @@ yes,yes)
 		    done
 		    rm -f "$GIT_DIR/TMP_ALT"
 		fi
-		git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD"
+		git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1
 		;;
 	http://*)
 		if test -z "@@NO_CURL@@"
diff --git a/git-fetch.sh b/git-fetch.sh
index ff1769952b..0c7a11d565 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -223,9 +223,16 @@ reflist=$(get_remote_refs_for_fetch "$@")
 if test "$tags"
 then
 	taglist=`IFS="	" &&
-		  git-ls-remote $upload_pack --tags "$remote" |
+		  (
+			git-ls-remote $upload_pack --tags "$remote" ||
+			echo fail ouch
+		  ) |
 	          while read sha1 name
 		  do
+			case "$sha1" in
+			fail)
+				exit 1
+			esac
 			case "$name" in
 			*^*) continue ;;
 			esac
@@ -235,7 +242,7 @@ then
 			else
 			    echo >&2 "warning: tag ${name} ignored"
 			fi
-		  done`
+		  done` || exit
 	if test "$#" -gt 1
 	then
 		# remote URL plus explicit refspecs; we need to merge them.
-- 
2.40.0