Skip to content

Commit f12ef30

Browse files
authored
Merge pull request #12303 from NixOS/fix-mingw-2
More mingw build fixes
2 parents ae7bc5f + 8e05ddf commit f12ef30

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/libfetchers/git.cc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ struct GitInputScheme : InputScheme
331331

332332
auto result = runProgram(RunOptions {
333333
.program = "git",
334-
.args = {"-C", *repoPath, "--git-dir", repoInfo.gitDir, "check-ignore", "--quiet", std::string(path.rel())},
334+
.args = {"-C", repoPath->string(), "--git-dir", repoInfo.gitDir, "check-ignore", "--quiet", std::string(path.rel())},
335335
});
336336
auto exitCode =
337337
#ifndef WIN32 // TODO abstract over exit status handling on Windows
@@ -344,15 +344,15 @@ struct GitInputScheme : InputScheme
344344
if (exitCode != 0) {
345345
// The path is not `.gitignore`d, we can add the file.
346346
runProgram("git", true,
347-
{ "-C", *repoPath, "--git-dir", repoInfo.gitDir, "add", "--intent-to-add", "--", std::string(path.rel()) });
347+
{ "-C", repoPath->string(), "--git-dir", repoInfo.gitDir, "add", "--intent-to-add", "--", std::string(path.rel()) });
348348

349349

350350
if (commitMsg) {
351351
// Pause the logger to allow for user input (such as a gpg passphrase) in `git commit`
352352
logger->pause();
353353
Finally restoreLogger([]() { logger->resume(); });
354354
runProgram("git", true,
355-
{ "-C", *repoPath, "--git-dir", repoInfo.gitDir, "commit", std::string(path.rel()), "-F", "-" },
355+
{ "-C", repoPath->string(), "--git-dir", repoInfo.gitDir, "commit", std::string(path.rel()), "-F", "-" },
356356
*commitMsg);
357357
}
358358
}
@@ -470,7 +470,7 @@ struct GitInputScheme : InputScheme
470470
return repoInfo;
471471
}
472472

473-
uint64_t getLastModified(const RepoInfo & repoInfo, const std::string & repoDir, const Hash & rev) const
473+
uint64_t getLastModified(const RepoInfo & repoInfo, const std::filesystem::path & repoDir, const Hash & rev) const
474474
{
475475
Cache::Key key{"gitLastModified", {{"rev", rev.gitRev()}}};
476476

@@ -486,7 +486,7 @@ struct GitInputScheme : InputScheme
486486
return lastModified;
487487
}
488488

489-
uint64_t getRevCount(const RepoInfo & repoInfo, const std::string & repoDir, const Hash & rev) const
489+
uint64_t getRevCount(const RepoInfo & repoInfo, const std::filesystem::path & repoDir, const Hash & rev) const
490490
{
491491
Cache::Key key{"gitRevCount", {{"rev", rev.gitRev()}}};
492492

@@ -557,30 +557,30 @@ struct GitInputScheme : InputScheme
557557
auto ref = originalRef ? *originalRef : getDefaultRef(repoInfo);
558558
input.attrs.insert_or_assign("ref", ref);
559559

560-
Path repoDir;
560+
std::filesystem::path repoDir;
561561

562562
if (auto repoPath = repoInfo.getPath()) {
563563
repoDir = *repoPath;
564564
if (!input.getRev())
565565
input.attrs.insert_or_assign("rev", GitRepo::openRepo(repoDir)->resolveRef(ref).gitRev());
566566
} else {
567567
auto repoUrl = std::get<ParsedURL>(repoInfo.location);
568-
Path cacheDir = getCachePath(repoUrl.to_string(), getShallowAttr(input));
568+
std::filesystem::path cacheDir = getCachePath(repoUrl.to_string(), getShallowAttr(input));
569569
repoDir = cacheDir;
570570
repoInfo.gitDir = ".";
571571

572-
createDirs(dirOf(cacheDir));
573-
PathLocks cacheDirLock({cacheDir});
572+
std::filesystem::create_directories(cacheDir.parent_path());
573+
PathLocks cacheDirLock({cacheDir.string()});
574574

575575
auto repo = GitRepo::openRepo(cacheDir, true, true);
576576

577577
// We need to set the origin so resolving submodule URLs works
578578
repo->setRemote("origin", repoUrl.to_string());
579579

580-
Path localRefFile =
580+
auto localRefFile =
581581
ref.compare(0, 5, "refs/") == 0
582-
? cacheDir + "/" + ref
583-
: cacheDir + "/refs/heads/" + ref;
582+
? cacheDir / ref
583+
: cacheDir / "refs/heads" / ref;
584584

585585
bool doFetch;
586586
time_t now = time(0);
@@ -596,7 +596,7 @@ struct GitInputScheme : InputScheme
596596
/* If the local ref is older than ‘tarball-ttl’ seconds, do a
597597
git fetch to update the local ref to the remote ref. */
598598
struct stat st;
599-
doFetch = stat(localRefFile.c_str(), &st) != 0 ||
599+
doFetch = stat(localRefFile.string().c_str(), &st) != 0 ||
600600
!isCacheFileWithinTtl(now, st);
601601
}
602602
}
@@ -616,7 +616,7 @@ struct GitInputScheme : InputScheme
616616

617617
repo->fetch(repoUrl.to_string(), fmt("%s:%s", fetchRef, fetchRef), getShallowAttr(input));
618618
} catch (Error & e) {
619-
if (!pathExists(localRefFile)) throw;
619+
if (!std::filesystem::exists(localRefFile)) throw;
620620
logError(e.info());
621621
warn("could not update local clone of Git repository '%s'; continuing with the most recent version", repoInfo.locationToArg());
622622
}
@@ -850,7 +850,7 @@ struct GitInputScheme : InputScheme
850850
for (auto & file : repoInfo.workdirInfo.dirtyFiles) {
851851
writeString("modified:", hashSink);
852852
writeString(file.abs(), hashSink);
853-
dumpPath(*repoPath / file.rel(), hashSink);
853+
dumpPath((*repoPath / file.rel()).string(), hashSink);
854854
}
855855
for (auto & file : repoInfo.workdirInfo.deletedFiles) {
856856
writeString("deleted:", hashSink);

src/libflake/flake/flake.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ LockedFlake lockFlake(
783783
auto relPath = (topRef.subdir == "" ? "" : topRef.subdir + "/") + "flake.lock";
784784
auto outputLockFilePath = *sourcePath / relPath;
785785

786-
bool lockFileExists = pathExists(outputLockFilePath);
786+
bool lockFileExists = fs::symlink_exists(outputLockFilePath);
787787

788788
auto s = chomp(diff);
789789
if (lockFileExists) {

src/nix/upgrade-nix.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
9797

9898
// FIXME: don't call an external process.
9999
runProgram(getNixBin("nix-env").string(), false,
100-
{"--profile", profileDir, "-i", store->printStorePath(storePath), "--no-sandbox"});
100+
{"--profile", profileDir.string(), "-i", store->printStorePath(storePath), "--no-sandbox"});
101101
}
102102

103103
printInfo(ANSI_GREEN "upgrade to version %s done" ANSI_NORMAL, version);
@@ -120,7 +120,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
120120

121121
// Resolve profile to /nix/var/nix/profiles/<name> link.
122122
while (canonPath(profileDir.string()).find("/profiles/") == std::string::npos && std::filesystem::is_symlink(profileDir))
123-
profileDir = readLink(profileDir);
123+
profileDir = readLink(profileDir.string());
124124

125125
printInfo("found profile %s", profileDir);
126126

0 commit comments

Comments
 (0)