All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] receive-pack: Create a HEAD ref for ref namespace
@ 2015-06-01 21:24 Johannes Löthberg
  2015-06-05 11:53 ` Johannes Löthberg
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Johannes Löthberg @ 2015-06-01 21:24 UTC (permalink / raw)
  To: git; +Cc: Johannes Löthberg

Each ref namespace have their own separate branches, tags, and HEAD, so
when pushing to a namespace we need to make sure that there exists a
HEAD ref for the namespace, otherwise you will not be able to check out
the repo after cloning from a namespace
---

So, I have absolutely no clue where this should actually be put, so I 
just put it where it fit for now.

Any comments on where to put it, or comments on the patch in general?

 builtin/receive-pack.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 5292bb5..c189838 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -864,7 +864,9 @@ static const char *update(struct command *cmd, struct shallow_info *si)
 {
 	const char *name = cmd->ref_name;
 	struct strbuf namespaced_name_buf = STRBUF_INIT;
-	const char *namespaced_name, *ret;
+	struct strbuf namespaced_head_buf = STRBUF_INIT;
+	const char *namespaced_name, *ret, *namespace;
+	const char *namespaced_head_path;
 	unsigned char *old_sha1 = cmd->old_sha1;
 	unsigned char *new_sha1 = cmd->new_sha1;
 
@@ -981,6 +983,14 @@ static const char *update(struct command *cmd, struct shallow_info *si)
 		return NULL; /* good */
 	}
 	else {
+		namespace = get_git_namespace();
+		if (strcmp(namespace, "refs/namespaces/")) {
+			strbuf_addf(&namespaced_head_buf, "%s%s", namespace, "HEAD");
+			namespaced_head_path = strbuf_detach(&namespaced_head_buf, NULL);
+
+			create_symref(namespaced_head_path, namespaced_name, NULL);
+		}
+
 		struct strbuf err = STRBUF_INIT;
 		if (shallow_update && si->shallow_ref[cmd->index] &&
 		    update_shallow_ref(cmd, si))
-- 
2.4.2

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

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

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-01 21:24 [PATCH] receive-pack: Create a HEAD ref for ref namespace Johannes Löthberg
2015-06-05 11:53 ` Johannes Löthberg
2015-06-05 12:55   ` Michael J Gruber
2015-06-05 13:50     ` Johannes Löthberg
2015-06-05 14:10     ` Johannes Löthberg
2015-06-05 14:12 ` [PATCH v2] Fix cloning from " Johannes Löthberg
2015-06-05 14:12   ` [PATCH v2 1/2] receive-pack: Create a HEAD ref for " Johannes Löthberg
2015-06-05 14:12   ` [PATCH v2 2/2] t: Add test for cloning from " Johannes Löthberg
2015-06-05 15:33     ` Junio C Hamano
2015-06-05 16:12       ` Johannes Löthberg
2015-06-05 16:22         ` Junio C Hamano
2015-06-05 16:31           ` Johannes Löthberg
2015-06-05 16:25         ` Johannes Löthberg
2015-06-05 16:46           ` Junio C Hamano
2015-06-05 17:02 ` [PATCH v3] receive-pack: Create a HEAD ref for " Johannes Löthberg
2015-06-05 17:08   ` Johannes Löthberg
2015-06-05 17:19   ` Junio C Hamano
2015-06-05 17:27     ` Johannes Löthberg
2015-06-05 17:42 ` [PATCH v4] " Johannes Löthberg
2015-06-10 23:39   ` Johannes Löthberg
2015-06-15 20:48   ` Junio C Hamano
2015-06-15 20:59     ` Johannes Löthberg

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.