All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC] upload-pack: Fail if cloning empty namespace
@ 2015-06-12 20:15 Johannes Löthberg
  2015-06-12 21:01 ` Junio C Hamano
  2015-06-12 22:17 ` [PATCH v2] " Johannes Löthberg
  0 siblings, 2 replies; 11+ messages in thread
From: Johannes Löthberg @ 2015-06-12 20:15 UTC (permalink / raw)
  To: git; +Cc: Johannes Löthberg

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-06-21 18:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 20:15 [PATCH/RFC] upload-pack: Fail if cloning empty namespace Johannes Löthberg
2015-06-12 21:01 ` Junio C Hamano
2015-06-12 22:17 ` [PATCH v2] " Johannes Löthberg
2015-06-12 22:32   ` Johannes Löthberg
2015-06-15 20:49     ` Junio C Hamano
2015-06-20 14:27       ` Johannes Löthberg
2015-06-20 18:06         ` Junio C Hamano
2015-06-20 18:13           ` Johannes Löthberg
2015-06-20 21:20           ` Junio C Hamano
2015-06-20 21:49             ` Johannes Löthberg
2015-06-21 18:43               ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.