summaryrefslogtreecommitdiff
path: root/builtin/receive-pack.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@lfos.de>2015-11-03 07:58:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-11-05 19:25:02 (GMT)
commit78a766ab6eaaa91c2638158bd4fda06a93291da0 (patch)
tree3318ee5a30e7227c2c20b46d2a8b7118ed8d3050 /builtin/receive-pack.c
parent00b293e519d1aa0c5b57ae9359ec5306d7023b3f (diff)
downloadgit-78a766ab6eaaa91c2638158bd4fda06a93291da0.zip
git-78a766ab6eaaa91c2638158bd4fda06a93291da0.tar.gz
git-78a766ab6eaaa91c2638158bd4fda06a93291da0.tar.bz2
hideRefs: add support for matching full refs
In addition to matching stripped refs, one can now add hideRefs patterns that the full (unstripped) ref is matched against. To distinguish between stripped and full matches, those new patterns must be prefixed with a circumflex (^). This commit also removes support for the undocumented and unintended hideRefs settings ".have" (suppressing all "have" lines) and "capabilities^{}" (suppressing the capabilities line). Signed-off-by: Lukas Fleischer <lfleischer@lfos.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/receive-pack.c')
-rw-r--r--builtin/receive-pack.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index bcb624b..f06f70a 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 {
@@ -219,9 +216,14 @@ 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)
+static int show_ref_cb(const char *path_full, const struct object_id *oid,
+ int flag, void *unused)
{
- path = strip_namespace(path);
+ const char *path = strip_namespace(path_full);
+
+ if (ref_is_hidden(path, path_full))
+ return 0;
+
/*
* Advertise refs outside our current namespace as ".have"
* refs, so that the client can use them to minimize data
@@ -1195,16 +1197,29 @@ static int iterate_receive_command_list(void *cb_data, unsigned char sha1[20])
static void reject_updates_to_hidden(struct command *commands)
{
+ struct strbuf refname_full = STRBUF_INIT;
+ size_t prefix_len;
struct command *cmd;
+ strbuf_addstr(&refname_full, get_git_namespace());
+ prefix_len = refname_full.len;
+
for (cmd = commands; cmd; cmd = cmd->next) {
- if (cmd->error_string || !ref_is_hidden(cmd->ref_name))
+ if (cmd->error_string)
+ continue;
+
+ strbuf_setlen(&refname_full, prefix_len);
+ strbuf_addstr(&refname_full, cmd->ref_name);
+
+ if (!ref_is_hidden(cmd->ref_name, refname_full.buf))
continue;
if (is_null_sha1(cmd->new_sha1))
cmd->error_string = "deny deleting a hidden ref";
else
cmd->error_string = "deny updating a hidden ref";
}
+
+ strbuf_release(&refname_full);
}
static int should_process_cmd(struct command *cmd)