diff --git a/src/libfetchers/git-utils.cc b/src/libfetchers/git-utils.cc index 8eefb1082..e9cee55af 100644 --- a/src/libfetchers/git-utils.cc +++ b/src/libfetchers/git-utils.cc @@ -318,7 +318,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this std::vector> getSubmodules(const Hash & rev, bool exportIgnore) override; - void smudgeLfs() override; + //void smudgeLfs() override; std::string resolveSubmoduleUrl( const std::string & url, @@ -495,6 +495,17 @@ ref GitRepo::openRepo(const std::filesystem::path & path, bool create, /** * Raw git tree input accessor. */ + +static int attr_callback(const char *name, const char *value, void *payload) { + warn("got an attribute! it's %s = %s", name, value); + return 0; + //// Check if the attribute is a filter attribute + //if (strncmp(name, "filter.", 7) == 0) { + // printf("Filter attribute: %s\n", name); + //} + //return 0; // Continue iterating +} + struct GitInputAccessor : InputAccessor { ref repo; @@ -510,7 +521,15 @@ struct GitInputAccessor : InputAccessor { auto blob = getBlob(path, symlink); + int error; // read filters here, perform smudge + + // TODO: fix git_attr_foreach here, it can't seem to parse `.gitattributes` here even though it should + warn("on path %s", path.abs().c_str()); + if ((error = git_attr_foreach(&(*(*repo).repo), GIT_ATTR_CHECK_INCLUDE_HEAD, path.rel_c_str(), attr_callback, NULL)) < 0) { + warn("git_attr_foreach: %s", git_error_last()->message); + } + auto data = std::string_view((const char *) git_blob_rawcontent(blob.get()), git_blob_rawsize(blob.get())); return std::string(data); @@ -1010,14 +1029,14 @@ std::vector> GitRepoImpl::getSubmodules return result; } -void GitRepoImpl::smudgeLfs() { - runProgram(RunOptions{ - .program = "git", - .searchPath = true, - .args = { "lfs", "pull" }, - .chdir = std::make_optional(this->path) - }); -} +//void GitRepoImpl::smudgeLfs() { +// runProgram(RunOptions{ +// .program = "git", +// .searchPath = true, +// .args = { "lfs", "pull" }, +// .chdir = std::make_optional(this->path) +// }); +//} ref getTarballCache() { diff --git a/src/libfetchers/git-utils.hh b/src/libfetchers/git-utils.hh index c45de06dc..551557fa7 100644 --- a/src/libfetchers/git-utils.hh +++ b/src/libfetchers/git-utils.hh @@ -69,7 +69,7 @@ struct GitRepo */ virtual std::vector> getSubmodules(const Hash & rev, bool exportIgnore) = 0; - virtual void smudgeLfs() = 0; + //virtual void smudgeLfs() = 0; virtual std::string resolveSubmoduleUrl( const std::string & url, diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index 44fe30f20..5ef5e7471 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -655,8 +655,9 @@ struct GitInputScheme : InputScheme } if (getLfsAttr(input)) { + warn("lfs attr set on %s", input.to_string()); // urlencoded `?lfs=1` param is set, - repo->smudgeLfs(); + //repo->smudgeLfs(); } assert(!origRev || origRev == rev);