@@ -632,6 +632,13 @@ Note that the configured value is executed in a shell, and thus
linkgit:git-for-each-ref[1] by itself does not work, as scripts have to handle
the path argument specially.
+core.alternateRefsPrefixes::
+ When listing references from an alternate, list only references that begin
+ with the given prefix. Prefixes match as if they were given as arguments to
+ linkgit:git-for-each-ref[1]. To list multiple prefixes, separate them with
+ whitespace. If `core.alternateRefsCommand` is set, setting
+ `core.alternateRefsPrefixes` has no effect.
+
core.bare::
If true this repository is assumed to be 'bare' and has no
working directory associated with it. If this is the case a
@@ -30,4 +30,12 @@ test_expect_success 'with core.alternateRefsCommand' '
test_cmp expect actual.haves
'
+test_expect_success 'with core.alternateRefsPrefixes' '
+ test_config -C fork core.alternateRefsPrefixes "refs/heads/private" &&
+ git rev-parse private/branch >expect &&
+ printf "0000" | git receive-pack fork >actual &&
+ extract_haves <actual >actual.haves &&
+ test_cmp expect actual.haves
+'
+
test_done
@@ -1341,6 +1341,11 @@ static void fill_alternate_refs_command(struct child_process *cmd,
argv_array_pushf(&cmd->args, "--git-dir=%s", repo_path);
argv_array_push(&cmd->args, "for-each-ref");
argv_array_push(&cmd->args, "--format=%(objectname)");
+
+ if (!git_config_get_value("core.alternateRefsPrefixes", &value)) {
+ argv_array_push(&cmd->args, "--");
+ argv_array_split(&cmd->args, value);
+ }
}
cmd->env = local_repo_env;