diff options
| author | kdj0c <kdj0c@djinvi.net> | 2019-12-05 10:43:17 +0100 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2020-01-06 15:03:01 +0100 |
| commit | 42e0bed26ea62cbd3b69ba6d31686c21aa5bb12d (patch) | |
| tree | c678f30c685f8911935b4127cea2da089c6a65e4 /src | |
| parent | 2f6f10bb804becddfae78bb9682183ae8ae8184d (diff) | |
| download | libgit2-42e0bed26ea62cbd3b69ba6d31686c21aa5bb12d.tar.gz | |
Fix git_submodule_sync with relative url
git_submodule_sync should resolve submodule before writing to .git/config
to have the same behavior as git_submodule_init, which does the right thing.
Diffstat (limited to 'src')
| -rw-r--r-- | src/submodule.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/submodule.c b/src/submodule.c index d12dbcfee..78ce7c768 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -1422,7 +1422,7 @@ int git_submodule_sync(git_submodule *sm) { int error = 0; git_config *cfg = NULL; - git_buf key = GIT_BUF_INIT; + git_buf key = GIT_BUF_INIT, effective_submodule_url = GIT_BUF_INIT; git_repository *smrepo = NULL; if (!sm->url) { @@ -1434,8 +1434,9 @@ int git_submodule_sync(git_submodule *sm) /* copy URL over to config only if it already exists */ if (!(error = git_repository_config__weakptr(&cfg, sm->repo)) && - !(error = git_buf_printf(&key, "submodule.%s.url", sm->name))) - error = git_config__update_entry(cfg, key.ptr, sm->url, true, true); + !(error = git_buf_printf(&key, "submodule.%s.url", sm->name)) && + !(error = git_submodule_resolve_url(&effective_submodule_url, sm->repo, sm->url))) + error = git_config__update_entry(cfg, key.ptr, effective_submodule_url.ptr, true, true); /* if submodule exists in the working directory, update remote url */ @@ -1457,12 +1458,13 @@ int git_submodule_sync(git_submodule *sm) } if (!error) - error = git_config__update_entry(cfg, key.ptr, sm->url, true, false); + error = git_config__update_entry(cfg, key.ptr, effective_submodule_url.ptr, true, false); git_repository_free(smrepo); } git_buf_dispose(&key); + git_buf_dispose(&effective_submodule_url); return error; } |
