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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---

Changes since v1:

* Fixed the namespace check, since I apparently forgot to check with a
  bare repo in my last test. D'oh.

Two other options for this would be to either add a 
get_git_namespace_len() function and use that, or a is_namespaced() 
functon. But since it's only used here for now at least it feels simpler 
to not bloat the codabase with another function which has no other use.

 upload-pack.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/upload-pack.c b/upload-pack.c
index 89e832b..99fb271 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 (strcmp(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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]