forked from lix-project/lix
Revert libgit2 fetching
libgit2 is not capable of using git-credentials helpers yet. This prevents private repositories from being used. Based on code that was replaced in https://github.com/NixOS/nix/pull/9240 (Introduce libgit2); hence: Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This commit is contained in:
parent
76a50b3a69
commit
8d422c2fef
1 changed files with 12 additions and 19 deletions
|
@ -383,27 +383,20 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
|
||||||
{
|
{
|
||||||
Activity act(*logger, lvlTalkative, actFetchTree, fmt("fetching Git repository '%s'", url));
|
Activity act(*logger, lvlTalkative, actFetchTree, fmt("fetching Git repository '%s'", url));
|
||||||
|
|
||||||
Remote remote;
|
// TODO: implement git-credential helper support (preferably via libgit2, which as of 2024-01 does not support that)
|
||||||
|
// then use code that was removed in this commit (see blame)
|
||||||
|
|
||||||
if (git_remote_create_anonymous(Setter(remote), *this, url.c_str()))
|
auto dir = this->path;
|
||||||
throw Error("cannot create Git remote '%s': %s", url, git_error_last()->message);
|
|
||||||
|
|
||||||
char * refspecs[] = {(char *) refspec.c_str()};
|
runProgram(RunOptions {
|
||||||
git_strarray refspecs2 {
|
.program = "git",
|
||||||
.strings = refspecs,
|
.searchPath = true,
|
||||||
.count = 1
|
// FIXME: git stderr messes up our progress indicator, so
|
||||||
};
|
// we're using --quiet for now. Should process its stderr.
|
||||||
|
.args = { "-C", path.abs(), "fetch", "--quiet", "--force", "--", url, refspec },
|
||||||
git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
|
.input = {},
|
||||||
// FIXME: for some reason, shallow fetching over ssh barfs
|
.isInteractive = true
|
||||||
// with "could not read from remote repository".
|
});
|
||||||
opts.depth = shallow && parseURL(url).scheme != "ssh" ? 1 : GIT_FETCH_DEPTH_FULL;
|
|
||||||
opts.callbacks.payload = &act;
|
|
||||||
opts.callbacks.sideband_progress = sidebandProgressCallback;
|
|
||||||
opts.callbacks.transfer_progress = transferProgressCallback;
|
|
||||||
|
|
||||||
if (git_remote_fetch(remote.get(), &refspecs2, &opts, nullptr))
|
|
||||||
throw Error("fetching '%s' from '%s': %s", refspec, url, git_error_last()->message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void verifyCommit(
|
void verifyCommit(
|
||||||
|
|
Loading…
Reference in a new issue