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

[PATCH/RFC] upload-pack: Fail if cloning empty namespace

From
Johannes Löthberg <johannes@kyriasis.com>
Date
Jun 12, 2015, 20:15 UTC
Message-ID
<1434140115-3139-1-git-send-email-johannes@kyriasis.com>

Git should fail to clone if trying to clone from an non-existing ref namespace, since it's the same as a non-existing repository

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
---

In version 4 of the ArchLinux User Repository, which is a hosting platform for recepies for building Arch packages, we use Git to store the recepies.

To save space we are using ref namespaces, which so far has saved quite a bit of space. There is one issue though, when cloning a non-existing repository we don't want the clone to work. This patch fixes this issue by failing the clone if a namespace was specified but it doesn't exist.

Making this conditional on a namespace being specified makes sure that cloning regular empty repos still works.

 upload-pack.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/upload-pack.c b/upload-pack.c
index 89e832b..21f8891 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -778,6 +778,10 @@ static void upload_pack(void)
 
 	head_ref_namespaced(find_symref, &symref);
 
+	if (get_git_namespace() && !symref.items) {
+		die("git upload-pack: tried to clone from empty namespace");
+	}
+
 	if (advertise_refs || !stateless_rpc) {
 		reset_timeout();
 		head_ref_namespaced(send_ref, &symref);
-- 
2.4.2
Next: Junio C Hamano
Message 1 of 11 in “upload-pack: Fail if cloning empty namespace”
  1. upload-pack: Fail if cloning empty namespaceJohannes Löthberg, Jun 12, 2015
  2. Junio C HamanoJun 12, 2015
  3. upload-pack: Fail if cloning empty namespaceJohannes Löthberg, Jun 12, 2015
  4. Johannes LöthbergJun 12, 2015
  5. Junio C HamanoJun 15, 2015
  6. Johannes LöthbergJun 20, 2015
  7. Junio C HamanoJun 20, 2015
  8. Johannes LöthbergJun 20, 2015
  9. Junio C HamanoJun 20, 2015
  10. Johannes LöthbergJun 20, 2015
  11. Junio C HamanoJun 21, 2015

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.