Skip to content

Commit

Permalink
Use libgit2 with ssh-exec support
Browse files Browse the repository at this point in the history
See libgit2/libgit2#6617. This ensures that we
get support for ~/.ssh/config, known_hosts etc.
  • Loading branch information
edolstra committed Nov 14, 2023
1 parent cf59ea8 commit 21bb180
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
inputs.lowdown-src = { url = "github:kristapsdz/lowdown"; flake = false; };
inputs.flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
inputs.libgit2 = { url = "github:libgit2/libgit2"; flake = false; };

outputs = { self, nixpkgs, nixpkgs-regression, lowdown-src, flake-compat }:
outputs = { self, nixpkgs, nixpkgs-regression, lowdown-src, flake-compat, libgit2 }:

let
inherit (nixpkgs) lib;
Expand Down Expand Up @@ -194,7 +195,11 @@
bzip2 xz brotli editline
openssl sqlite
libarchive
libgit2
(pkgs.libgit2.overrideAttrs (attrs: {
src = libgit2;
version = libgit2.lastModifiedDate;
cmakeFlags = (attrs.cmakeFlags or []) ++ ["-DUSE_SSH=exec"];
}))
boost
lowdown-nix
libsodium
Expand Down
17 changes: 0 additions & 17 deletions src/libfetchers/git-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,6 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
const std::string & url,
const std::string & refspec) override
{
/* FIXME: use libgit2. Unfortunately, it doesn't support
ssh_config at the moment. */
#if 0
Remote remote;

if (git_remote_create_anonymous(Setter(remote), *this, url.c_str()))
Expand All @@ -352,20 +349,6 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>

if (git_remote_fetch(remote.get(), &refspecs2, nullptr, nullptr))
throw Error("fetching '%s' from '%s': %s", refspec, url, git_error_last()->message);
#endif

// FIXME: git stderr messes up our progress indicator, so
// we're using --quiet for now. Should process its stderr.
runProgram("git", true,
{ "-C", path.abs(),
"--bare",
"fetch",
"--quiet",
"--force",
"--",
url,
refspec
}, {}, true);
}

void verifyCommit(
Expand Down

0 comments on commit 21bb180

Please sign in to comment.