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

[PATCH] clear error message for clone a gitweb URL

From
LYLiu Yubao <yubao.liu@gmail.com>
Date
Nov 8, 2006, 07:25 UTC
Message-ID
<4551864D.3010301@gmail.com>

When clone a gitweb URL, git reports "Can't lock ref", it's not clear for users, this patch adds clear error message for this case.

diff --git a/fetch.c b/fetch.c
index c426c04..40c5183 100644
--- a/fetch.c
+++ b/fetch.c
@@ -266,6 +266,14 @@ int pull(int targets, char **target, con
 		if (!write_ref || !write_ref[i])
 			continue;
 
+		if (*write_ref[i] == '\0') {
+			if (strncmp(write_ref_log_details, "http", 4) == 0)
+				error("Can't feed empty ref, seems you are fetching from a gitweb URL, "
+				      "check it in web browser for git URL.");
+			else
+				error("Can't feed empty ref");
+			goto unlock_and_fail;
+		}
 		lock[i] = lock_ref_sha1(write_ref[i], NULL);
 		if (!lock[i]) {
 			error("Can't lock ref %s", write_ref[i]);
diff --git a/git-clone.sh b/git-clone.sh
index 3f006d1..c8274e0 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -55,6 +55,10 @@ Perhaps git-update-server-info needs to
 		else
 			tname=$name
 		fi
+		if [ -z "$tname" -o -z "$name" ]; then
+			die "Cannot feed empty ref or commit-id, seems you are fetching
+from a gitweb URL, check it in web browser for git URL."
+		fi
 		git-http-fetch -v -a -w "$tname" "$name" "$1/" || exit 1
 	done <"$clone_tmp/refs"
Next: Junio C Hamano
Message 1 of 3 in “clear error message for clone a gitweb URL”
  1. clear error message for clone a gitweb URLLiu Yubao, Nov 8, 2006
  2. Junio C HamanoNov 8, 2006
  3. Liu YubaoNov 9, 2006

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.