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

Re: [PATCH/RFC] receive-pack: allow for hiding refs outside the namespace

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 27, 2015, 18:18 UTC
Message-ID
<xmqqfv0wcgzx.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20151027143207.18755.82151@s-8d3a2f8b.on.site.uni-stuttgart.de>
Lukas Fleischer <lfleischer@lfos.de> writes:
Show 9 quoted lines
> 2. transfer.hideRefs and receive.hideRefs do not seem to work with Git
>    namespaces in general. show_ref_cb() replaces each ref outside the
>    current namespace with ".have" before passing it to show_ref() which
>    in turn performs the ref_is_hidden() check. This has the nice side
>    effect that receive.hideRefs=.have does exactly what I want, however
>    it also means that hideRefs feature does not allow for excluding only
>    specific tags outside the current namespace. Is that intended? Can we
>    rely on Git always looking for ".have" in the hideRefs list in this
>    case?

When I asked 'Is transfer.hiderefs insufficient?', I wasn't expecting it to be usable out of box. It was a suggestion to build on top of it, instead of adding a parallel support for something specific to namespaces.

For example, if the problem is that you cannot tell ref_is_hidden() what namespace the ref is from because it is called after running strip_namespace(), perhaps you can find a way to have the original "namespaced ref" specified on transfer.hiderefs and match them? Then in repository for project A, namespaced refs for project B can be excluded by specifying refs/namespaces/B/* on transfer.hiderefs.

Perhaps along the lines of this?
 builtin/receive-pack.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index bcb624b..db0a99d 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -221,6 +221,15 @@ static void show_ref(const char *path, const unsigned char *sha1)
 
 static int show_ref_cb(const char *path, const struct object_id *oid, int flag, void *unused)
 {
+	const char *ns = get_git_namespace();
+
+	/*
+	 * Give the "hiderefs" mechanism a chance to inspect and
+	 * reject the namespaced ref itself.
+	 */
+	if (ns[0] && ref_is_hidden(path))
+		return 0;
+
 	path = strip_namespace(path);
 	/*
 	 * Advertise refs outside our current namespace as ".have"
Previous: Lukas FleischerNext: Lukas Fleischer
Message 11 of 17 in “receive-pack: allow for hiding refs outside the namespace”
  1. receive-pack: allow for hiding refs outside the namespaceLukas Fleischer, Oct 26, 2015
  2. Junio C HamanoOct 26, 2015
  3. Allow hideRefs to match refs outside the namespaceLukas Fleischer, Oct 28, 2015
  4. Junio C HamanoOct 28, 2015
  5. Lukas FleischerOct 31, 2015
  6. Junio C HamanoOct 31, 2015
  7. Lukas FleischerOct 31, 2015
  8. Lukas FleischerNov 1, 2015
  9. Junio C HamanoNov 1, 2015
  10. Lukas FleischerOct 27, 2015
  11. Junio C HamanoOct 27, 2015
  12. Lukas FleischerOct 28, 2015
  13. Jeff KingOct 28, 2015
  14. Junio C HamanoOct 28, 2015
  15. Junio C HamanoOct 30, 2015
  16. Jeff KingOct 30, 2015
  17. Lukas FleischerOct 31, 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.