-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't ignore unstaged files in local flakes #6858
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,18 +181,16 @@ WorkdirInfo getWorkdirInfo(const Input & input, const Path & workdir) | |
|
||
try { | ||
if (hasHead) { | ||
// Using git diff is preferrable over lower-level operations here, | ||
// because its conceptually simpler and we only need the exit code anyways. | ||
auto gitDiffOpts = Strings({ "-C", workdir, "--git-dir", gitDir, "diff", "HEAD", "--quiet"}); | ||
// Use git status --short to list changed and untracked files. | ||
// The output will be empty if there are none and the tree is clean | ||
auto gitDiffOpts = Strings({ "-C", workdir, "--git-dir", gitDir, "status", "--short"}); | ||
if (!submodules) { | ||
// Changes in submodules should only make the tree dirty | ||
// when those submodules will be copied as well. | ||
gitDiffOpts.emplace_back("--ignore-submodules"); | ||
} | ||
gitDiffOpts.emplace_back("--"); | ||
runProgram("git", true, gitDiffOpts); | ||
|
||
clean = true; | ||
clean = (chomp(runProgram("git", true, gitDiffOpts)) == ""); | ||
} | ||
} catch (ExecError & e) { | ||
if (!WIFEXITED(e.status) || WEXITSTATUS(e.status) != 1) throw; | ||
|
@@ -212,9 +210,13 @@ std::pair<StorePath, Input> fetchFromWorkdir(ref<Store> store, Input & input, co | |
if (fetchSettings.warnDirty) | ||
warn("Git tree '%s' is dirty", workdir); | ||
|
||
auto gitOpts = Strings({ "-C", workdir, "--git-dir", gitDir, "ls-files", "-z" }); | ||
auto gitOpts = Strings({ "-C", workdir, "--git-dir", gitDir, "ls-files", "--cached", "-z" }); | ||
if (submodules) | ||
gitOpts.emplace_back("--recurse-submodules"); | ||
else { | ||
gitOpts.emplace_back("--others"); | ||
gitOpts.emplace_back("--exclude-standard"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to have an option to not run the standard excludes? I would like to be able to have (Also see #12291 for an alternative approach.) |
||
} | ||
Comment on lines
+216
to
+219
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI the |
||
|
||
auto files = tokenizeString<std::set<std::string>>( | ||
runProgram("git", true, gitOpts), "\0"s); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this output is being parsed in a script it would probably be better to use
git status --porcelain
, as that output is guaranteed to be stable (whereasgit status --short
is not).