mirror of
https://github.com/git/git.git
synced 2026-01-11 13:23:12 +09:00
Merge branch 'tt/receive-pack-oo-namespace-symref-fix' into jch
"git receive-pack", when namespace is involved, segfaulted when a symbolic ref cross the namespace boundary. Comments? * tt/receive-pack-oo-namespace-symref-fix: receive-pack: fix crash on out-of-namespace symref
This commit is contained in:
commit
33201dcea3
@ -1645,7 +1645,6 @@ static void check_aliased_update_internal(struct command *cmd,
|
||||
cmd->error_string = "broken symref";
|
||||
return;
|
||||
}
|
||||
dst_name = strip_namespace(dst_name);
|
||||
|
||||
if (!(item = string_list_lookup(list, dst_name)))
|
||||
return;
|
||||
@ -1690,10 +1689,13 @@ static void check_aliased_updates(struct command *commands)
|
||||
{
|
||||
struct command *cmd;
|
||||
struct string_list ref_list = STRING_LIST_INIT_NODUP;
|
||||
struct strbuf ref_name = STRBUF_INIT;
|
||||
|
||||
for (cmd = commands; cmd; cmd = cmd->next) {
|
||||
struct string_list_item *item =
|
||||
string_list_append(&ref_list, cmd->ref_name);
|
||||
struct string_list_item *item;
|
||||
strbuf_reset(&ref_name);
|
||||
strbuf_addf(&ref_name, "%s%s", get_git_namespace(), cmd->ref_name);
|
||||
item = string_list_append(&ref_list, ref_name.buf);
|
||||
item->util = (void *)cmd;
|
||||
}
|
||||
string_list_sort(&ref_list);
|
||||
@ -1703,6 +1705,7 @@ static void check_aliased_updates(struct command *commands)
|
||||
check_aliased_update(cmd, &ref_list);
|
||||
}
|
||||
|
||||
strbuf_release(&ref_name);
|
||||
string_list_clear(&ref_list, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -175,4 +175,17 @@ test_expect_success 'denyCurrentBranch and unborn branch with ref namespace' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'pushing to symref pointing outside the namespace' '
|
||||
(
|
||||
cd pushee &&
|
||||
git symbolic-ref refs/namespaces/namespace/refs/heads/main refs/heads/main &&
|
||||
cd ../original &&
|
||||
git push pushee-namespaced main &&
|
||||
git ls-remote pushee-unnamespaced refs/heads/main >actual &&
|
||||
printf "$commit1\trefs/heads/main\n" >expected &&
|
||||
printf "$commit1\trefs/namespaces/namespace/refs/heads/main\n" >>expected &&
|
||||
test_cmp expected actual
|
||||
)
|
||||
'
|
||||
|
||||
test_done
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user