@@ -541,14 +541,15 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
541541 }
542542
543543 /* *
544- * A 'GitSourceAccessor' with no regard for export-ignore or any other transformations .
544+ * A 'GitSourceAccessor' with no regard for export-ignore.
545545 */
546- ref<GitSourceAccessor> getRawAccessor (const Hash & rev, bool smudgeLfs = false );
546+ ref<GitSourceAccessor> getRawAccessor (const Hash & rev, const GitAccessorOptions & options );
547547
548548 ref<SourceAccessor>
549- getAccessor (const Hash & rev, bool exportIgnore , std::string displayPrefix, bool smudgeLfs = false ) override ;
549+ getAccessor (const Hash & rev, const GitAccessorOptions & options , std::string displayPrefix) override ;
550550
551- ref<SourceAccessor> getAccessor (const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError e) override ;
551+ ref<SourceAccessor>
552+ getAccessor (const WorkdirInfo & wd, const GitAccessorOptions & options, MakeNotAllowedError e) override ;
552553
553554 ref<GitFileSystemObjectSink> getFileSystemObjectSink () override ;
554555
@@ -668,7 +669,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
668669
669670 Hash treeHashToNarHash (const fetchers::Settings & settings, const Hash & treeHash) override
670671 {
671- auto accessor = getAccessor (treeHash, false , " " );
672+ auto accessor = getAccessor (treeHash, {} , " " );
672673
673674 fetchers::Cache::Key cacheKey{" treeHashToNarHash" , {{" treeHash" , treeHash.gitRev ()}}};
674675
@@ -716,15 +717,17 @@ struct GitSourceAccessor : SourceAccessor
716717 ref<GitRepoImpl> repo;
717718 Object root;
718719 std::optional<lfs::Fetch> lfsFetch = std::nullopt ;
720+ GitAccessorOptions options;
719721 };
720722
721723 Sync<State> state_;
722724
723- GitSourceAccessor (ref<GitRepoImpl> repo_, const Hash & rev, bool smudgeLfs )
725+ GitSourceAccessor (ref<GitRepoImpl> repo_, const Hash & rev, const GitAccessorOptions & options )
724726 : state_{State{
725727 .repo = repo_,
726728 .root = peelToTreeOrBlob (lookupObject (*repo_, hashToOID (rev)).get ()),
727- .lfsFetch = smudgeLfs ? std::make_optional (lfs::Fetch (*repo_, hashToOID (rev))) : std::nullopt ,
729+ .lfsFetch = options.smudgeLfs ? std::make_optional (lfs::Fetch (*repo_, hashToOID (rev))) : std::nullopt ,
730+ .options = options,
728731 }}
729732 {
730733 }
@@ -1254,26 +1257,26 @@ struct GitFileSystemObjectSinkImpl : GitFileSystemObjectSink
12541257 }
12551258};
12561259
1257- ref<GitSourceAccessor> GitRepoImpl::getRawAccessor (const Hash & rev, bool smudgeLfs )
1260+ ref<GitSourceAccessor> GitRepoImpl::getRawAccessor (const Hash & rev, const GitAccessorOptions & options )
12581261{
12591262 auto self = ref<GitRepoImpl>(shared_from_this ());
1260- return make_ref<GitSourceAccessor>(self, rev, smudgeLfs );
1263+ return make_ref<GitSourceAccessor>(self, rev, options );
12611264}
12621265
12631266ref<SourceAccessor>
1264- GitRepoImpl::getAccessor (const Hash & rev, bool exportIgnore , std::string displayPrefix, bool smudgeLfs )
1267+ GitRepoImpl::getAccessor (const Hash & rev, const GitAccessorOptions & options , std::string displayPrefix)
12651268{
12661269 auto self = ref<GitRepoImpl>(shared_from_this ());
1267- ref<GitSourceAccessor> rawGitAccessor = getRawAccessor (rev, smudgeLfs );
1270+ ref<GitSourceAccessor> rawGitAccessor = getRawAccessor (rev, options );
12681271 rawGitAccessor->setPathDisplay (std::move (displayPrefix));
1269- if (exportIgnore)
1272+ if (options. exportIgnore )
12701273 return make_ref<GitExportIgnoreSourceAccessor>(self, rawGitAccessor, rev);
12711274 else
12721275 return rawGitAccessor;
12731276}
12741277
1275- ref<SourceAccessor>
1276- GitRepoImpl::getAccessor ( const WorkdirInfo & wd, bool exportIgnore , MakeNotAllowedError makeNotAllowedError)
1278+ ref<SourceAccessor> GitRepoImpl::getAccessor (
1279+ const WorkdirInfo & wd, const GitAccessorOptions & options , MakeNotAllowedError makeNotAllowedError)
12771280{
12781281 auto self = ref<GitRepoImpl>(shared_from_this ());
12791282 ref<SourceAccessor> fileAccessor = AllowListSourceAccessor::create (
@@ -1283,10 +1286,9 @@ GitRepoImpl::getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllow
12831286 boost::unordered_flat_set<CanonPath>{CanonPath::root},
12841287 std::move (makeNotAllowedError))
12851288 .cast <SourceAccessor>();
1286- if (exportIgnore)
1287- return make_ref<GitExportIgnoreSourceAccessor>(self, fileAccessor, std::nullopt );
1288- else
1289- return fileAccessor;
1289+ if (options.exportIgnore )
1290+ fileAccessor = make_ref<GitExportIgnoreSourceAccessor>(self, fileAccessor, std::nullopt );
1291+ return fileAccessor;
12901292}
12911293
12921294ref<GitFileSystemObjectSink> GitRepoImpl::getFileSystemObjectSink ()
@@ -1299,7 +1301,7 @@ std::vector<std::tuple<GitRepoImpl::Submodule, Hash>> GitRepoImpl::getSubmodules
12991301 /* Read the .gitmodules files from this revision. */
13001302 CanonPath modulesFile (" .gitmodules" );
13011303
1302- auto accessor = getAccessor (rev, exportIgnore, " " );
1304+ auto accessor = getAccessor (rev, {. exportIgnore = exportIgnore} , " " );
13031305 if (!accessor->pathExists (modulesFile))
13041306 return {};
13051307
@@ -1316,7 +1318,7 @@ std::vector<std::tuple<GitRepoImpl::Submodule, Hash>> GitRepoImpl::getSubmodules
13161318
13171319 std::vector<std::tuple<Submodule, Hash>> result;
13181320
1319- auto rawAccessor = getRawAccessor (rev);
1321+ auto rawAccessor = getRawAccessor (rev, {} );
13201322
13211323 for (auto & submodule : parseSubmodules (pathTemp)) {
13221324 /* Filter out .gitmodules entries that don't exist or are not
0 commit comments