Merge branch 'en/submodule-insteadof-remote-match'
The remote-matching logic for submodules has been corrected to resolve 'url.*.insteadOf' aliases before comparing the inventoried URL from '.gitmodules' with the URLs of configured remotes. * en/submodule-insteadof-remote-match: submodule: resolve insteadOf aliases when matching remotemain
commit
5f9197ea67
14
remote.c
14
remote.c
|
|
@ -1839,17 +1839,25 @@ const char *repo_default_remote(struct repository *repo)
|
||||||
|
|
||||||
const char *repo_remote_from_url(struct repository *repo, const char *url)
|
const char *repo_remote_from_url(struct repository *repo, const char *url)
|
||||||
{
|
{
|
||||||
|
char *rewritten_url;
|
||||||
|
const char *remote_name = NULL;
|
||||||
|
|
||||||
read_config(repo, 0);
|
read_config(repo, 0);
|
||||||
|
if ((rewritten_url = alias_url(url, &repo->remote_state->rewrites)))
|
||||||
|
url = rewritten_url;
|
||||||
|
|
||||||
for (int i = 0; i < repo->remote_state->remotes_nr; i++) {
|
for (int i = 0; i < repo->remote_state->remotes_nr; i++) {
|
||||||
struct remote *remote = repo->remote_state->remotes[i];
|
struct remote *remote = repo->remote_state->remotes[i];
|
||||||
if (!remote)
|
if (!remote)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (remote_has_url(remote, url))
|
if (remote_has_url(remote, url)) {
|
||||||
return remote->name;
|
remote_name = remote->name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
free(rewritten_url);
|
||||||
|
return remote_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int branch_has_merge_config(struct branch *branch)
|
int branch_has_merge_config(struct branch *branch)
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,25 @@ test_expect_success 'submodule update --remote should fetch upstream changes' '
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule update --remote resolves URL rewrites' '
|
||||||
|
test_config_global "url.$(pwd)/.insteadOf" local: &&
|
||||||
|
mkdir alias-super alias-submodule &&
|
||||||
|
(
|
||||||
|
cd alias-submodule &&
|
||||||
|
git init &&
|
||||||
|
git commit --allow-empty --message "Initial commit"
|
||||||
|
) &&
|
||||||
|
(
|
||||||
|
cd alias-super &&
|
||||||
|
git init &&
|
||||||
|
git submodule add local:alias-submodule submodule &&
|
||||||
|
git submodule update --force &&
|
||||||
|
git -C submodule remote rename origin upstream &&
|
||||||
|
git -C submodule remote add fork user@host &&
|
||||||
|
git submodule update --remote
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule update --remote should fetch upstream changes with .' '
|
test_expect_success 'submodule update --remote should fetch upstream changes with .' '
|
||||||
(
|
(
|
||||||
cd super &&
|
cd super &&
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue