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

[PATCH] Make curl fail on server error

From
CMCatalin Marinas <catalin.marinas@gmail.com>
Date
Aug 8, 2005, 09:53 UTC
Message-ID
<20050808095323.31602.76855.stgit@localhost.localdomain>

Some http servers return an HTML error page and git reads it as normal data. Adding -f option makes curl fail silently.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
---
 git-clone-dumb-http  |    2 +-
 git-fetch-script     |    2 +-
 git-ls-remote-script |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/git-clone-dumb-http b/git-clone-dumb-http
--- a/git-clone-dumb-http
+++ b/git-clone-dumb-http
@@ -14,7 +14,7 @@ if [ -n "$GIT_SSL_NO_VERIFY" ]; then
 fi
 http_fetch () {
 	# $1 = Remote, $2 = Local
-	curl -ns $curl_extra_args "$1" >"$2"
+	curl -nsf $curl_extra_args "$1" >"$2"
 }
 
 cd "$D" && 
diff --git a/git-fetch-script b/git-fetch-script
--- a/git-fetch-script
+++ b/git-fetch-script
@@ -15,7 +15,7 @@ http://* | https://*)
         fi
 	_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' &&
 	_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" &&
-	head=$(curl -ns $curl_extra_args "$merge_repo/$merge_head") &&
+	head=$(curl -nsf $curl_extra_args "$merge_repo/$merge_head") &&
 	expr "$head" : "$_x40\$" >/dev/null || {
 		echo >&2 "Failed to fetch $merge_head from $merge_repo"
 	        exit 1
diff --git a/git-ls-remote-script b/git-ls-remote-script
--- a/git-ls-remote-script
+++ b/git-ls-remote-script
@@ -46,7 +46,7 @@ http://* | https://* )
         if [ -n "$GIT_SSL_NO_VERIFY" ]; then
             curl_extra_args="-k"
         fi
-	curl -ns $curl_extra_args "$peek_repo/info/refs" || exit 1
+	curl -nsf $curl_extra_args "$peek_repo/info/refs" || exit 1
 	;;
 
 rsync://* )
Message 1 of 1 in “Make curl fail on server error”
  1. Make curl fail on server errorCatalin Marinas, Aug 8, 2005

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.