public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: "Johannes Löthberg" <johannes@kyriasis•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH v4] receive-pack: Create a HEAD ref for ref namespace
Date: Mon, 15 Jun 2015 13:48:02 -0700	[thread overview]
Message-ID: <xmqqlhfk7l6l.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1433526142-2413-1-git-send-email-johannes@kyriasis.com> ("Johannes Löthberg"'s message of "Fri, 5 Jun 2015 19:42:22 +0200")

Johannes Löthberg <johannes@kyriasis•com> writes:

> diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
> index d2ec52b..0c18c92 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);

In a normal environment without any namespace, get_git_namespace()
will return an empty string, which is not "refs/namespaces/", so we
create a symref HEAD (that is .git/HEAD) that points at whatever
name the command is about.  And this is done every time any ref is
updated, flipping the HEAD to point at whatever was pushed the last,
isn't it?

Why is this a good change?  I am puzzled...

> +		}
> +
>  		struct strbuf err = STRBUF_INIT;

This adds decl-after-stmt.

Going back to the proposed log message...

> 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

What this paragraph describes is entirely correct, I think.  But I
do not think receive-pack is the "we" in that paragraph.

When setting up a "namespace" a and b, shouldn't you be doing
essentially

	r=refs/namespaces/
	for ns in a b
        do
		git symbolic-ref $r$ns/HEAD $r$ns/refs/heads/master
	done

or something, which is an equivalent to what "git init" does to a
normal repository?

  parent reply	other threads:[~2015-06-15 20:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2015-06-15 20:59     ` Johannes Löthberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqlhfk7l6l.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=johannes@kyriasis$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox