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

[PATCH] Allow hideRefs to match refs outside the namespace

From
Lukas Fleischer <lfleischer@lfos.de>
Date
Oct 28, 2015, 15:42 UTC
Message-ID
<1446046920-15646-1-git-send-email-lfleischer@lfos.de>
In-Reply-To
<1445846999-8627-1-git-send-email-lfleischer@lfos.de>

Right now, refs with a path outside the current namespace are replaced by ".have" before passing them to show_ref() which in turn checks whether the ref matches the hideRefs pattern. Move the check before the path substitution in show_ref_cb() such that the hideRefs feature can be used to hide specific refs outside the current namespace.

Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
---
The other show_ref() call sites are in show_one_alternate_sha1() and in
write_head_info(). The call site in show_one_alternate_sha1() is for
alternates and passes ".have". The other one is
    show_ref("capabilities^{}", null_sha1);

and is not relevant to the hideRefs feature. Note that this kind of breaks backwards compatibility since the "magic" hideRefs patterns ".have" and "capabilities^{}" no longer work, as explained in the discussion.

 builtin/receive-pack.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index bcb624b..4a5d0ae 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -195,9 +195,6 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
 
 static void show_ref(const char *path, const unsigned char *sha1)
 {
-	if (ref_is_hidden(path))
-		return;
-
 	if (sent_capabilities) {
 		packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
 	} else {
@@ -221,6 +218,9 @@ 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)
 {
+	if (ref_is_hidden(path))
+		return 0;
+
 	path = strip_namespace(path);
 	/*
 	 * Advertise refs outside our current namespace as ".have"
-- 
2.6.2
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 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.