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

[PATCH] Support username and password inside URL

From
KVKalle Valo <kalle.valo@iki.fi>
Date
Nov 20, 2005, 10:05 UTC
Message-ID
<873blriqh0.fsf@litku.valo.iki.fi>
In-Reply-To
<87u0e71zpx.fsf@litku.valo.iki.fi>

Currently usage of curl was so that netrc was mandatory and passwords in URL weren't allowed. Change netrc to optional to make HTTP basic authentication with username and password in URL also work.

Here's an example of such URL:
http://foo:bar@www.example.com/auth.git/
Signed-off-by: Kalle Valo <Kalle.Valo@iki.fi>
---
 git-clone.sh     |    2 +-
 git-fetch.sh     |    2 +-
 git-ls-remote.sh |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

applies-to: 8839be40e9401452691ae1b0bf4c86ac616b7bb6 43a79922ab5d3468f0e8614d526b693772d8b1d6

diff --git a/git-clone.sh b/git-clone.sh
index c09979a..8af0d5f 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -23,7 +23,7 @@ fi
 
 http_fetch () {
 	# $1 = Remote, $2 = Local
-	curl -nsfL $curl_extra_args "$1" >"$2"
+	curl -sfL --netrc-optional $curl_extra_args "$1" >"$2"
 }
 
 clone_dumb_http () {
diff --git a/git-fetch.sh b/git-fetch.sh
index 6586e77..e983cef 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -234,7 +234,7 @@ do
 	    $u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
 	    print "$u";
 	' "$remote_name")
-	head=$(curl -nsfL $curl_extra_args "$remote/$remote_name_quoted") &&
+	head=$(curl -sfL --netrc-optional $curl_extra_args "$remote/$remote_name_quoted") &&
 	expr "$head" : "$_x40\$" >/dev/null ||
 		die "Failed to fetch $remote_name from $remote"
 	echo >&2 Fetching "$remote_name from $remote" using http
diff --git a/git-ls-remote.sh b/git-ls-remote.sh
index f0f0b07..af8f4b1 100755
--- a/git-ls-remote.sh
+++ b/git-ls-remote.sh
@@ -42,7 +42,7 @@ http://* | https://* )
         if [ -n "$GIT_SSL_NO_VERIFY" ]; then
             curl_extra_args="-k"
         fi
-	curl -nsf $curl_extra_args "$peek_repo/info/refs" ||
+	curl -sf --netrc-optional $curl_extra_args "$peek_repo/info/refs" ||
 		echo "failed	slurping"
 	;;
 
---
0.99.9.GIT
Previous: Kalle ValoNext: Junio C Hamano
Message 2 of 8 in “HTTP basic authentication support”
  1. Kalle ValoNov 20, 2005
  2. Support username and password inside URLKalle Valo, Nov 20, 2005
  3. Junio C HamanoNov 20, 2005
  4. Krzysztof HalasaNov 20, 2005
  5. Kalle ValoNov 23, 2005
  6. Junio C HamanoNov 24, 2005
  7. Johannes SchindelinNov 24, 2005
  8. Junio C HamanoNov 24, 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.