forked from lix-project/lix
Don't attempt to git add
ignored files
This uses `git check-ignore` to determine if files are ignored before attempting to add them in `putFile`. We also add a condition to the `fetchFromWorkdir` filter to always add the `flake.lock` file, even if it's not tracked. This is necessary to resolve inputs. This fixes #8854 without `git add --force`.
This commit is contained in:
parent
a8fea5a54f
commit
be30c2ea8d
|
@ -313,15 +313,26 @@ struct GitInputScheme : InputScheme
|
||||||
|
|
||||||
writeFile((CanonPath(repoInfo.url) + path).abs(), contents);
|
writeFile((CanonPath(repoInfo.url) + path).abs(), contents);
|
||||||
|
|
||||||
runProgram("git", true,
|
auto result = runProgram(RunOptions {
|
||||||
{ "-C", repoInfo.url, "--git-dir", repoInfo.gitDir, "add", "--intent-to-add", "--", std::string(path.rel()) });
|
.program = "git",
|
||||||
|
.args = {"-C", repoInfo.url, "--git-dir", repoInfo.gitDir, "check-ignore", "--quiet", std::string(path.rel())},
|
||||||
|
});
|
||||||
|
auto exitCode = WEXITSTATUS(result.first);
|
||||||
|
|
||||||
// Pause the logger to allow for user input (such as a gpg passphrase) in `git commit`
|
if (exitCode != 0) {
|
||||||
logger->pause();
|
// The path is not `.gitignore`d, we can add the file.
|
||||||
Finally restoreLogger([]() { logger->resume(); });
|
|
||||||
if (commitMsg)
|
|
||||||
runProgram("git", true,
|
runProgram("git", true,
|
||||||
{ "-C", repoInfo.url, "--git-dir", repoInfo.gitDir, "commit", std::string(path.rel()), "-m", *commitMsg });
|
{ "-C", repoInfo.url, "--git-dir", repoInfo.gitDir, "add", "--intent-to-add", "--", std::string(path.rel()) });
|
||||||
|
|
||||||
|
|
||||||
|
if (commitMsg) {
|
||||||
|
// Pause the logger to allow for user input (such as a gpg passphrase) in `git commit`
|
||||||
|
logger->pause();
|
||||||
|
Finally restoreLogger([]() { logger->resume(); });
|
||||||
|
runProgram("git", true,
|
||||||
|
{ "-C", repoInfo.url, "--git-dir", repoInfo.gitDir, "commit", std::string(path.rel()), "-m", *commitMsg });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RepoInfo
|
struct RepoInfo
|
||||||
|
|
Loading…
Reference in a new issue