mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 22:16:16 +02:00
Merge pull request #9324 from 9999years/fix-8854-take-2
Don't attempt to `git add` ignored files
This commit is contained in:
commit
359990dfdc
1 changed files with 18 additions and 7 deletions
|
@ -314,16 +314,27 @@ struct GitInputScheme : InputScheme
|
||||||
|
|
||||||
writeFile((CanonPath(repoInfo.url) + path).abs(), contents);
|
writeFile((CanonPath(repoInfo.url) + path).abs(), contents);
|
||||||
|
|
||||||
|
auto result = runProgram(RunOptions {
|
||||||
|
.program = "git",
|
||||||
|
.args = {"-C", repoInfo.url, "--git-dir", repoInfo.gitDir, "check-ignore", "--quiet", std::string(path.rel())},
|
||||||
|
});
|
||||||
|
auto exitCode = WEXITSTATUS(result.first);
|
||||||
|
|
||||||
|
if (exitCode != 0) {
|
||||||
|
// The path is not `.gitignore`d, we can add the file.
|
||||||
runProgram("git", true,
|
runProgram("git", true,
|
||||||
{ "-C", repoInfo.url, "--git-dir", repoInfo.gitDir, "add", "--intent-to-add", "--", std::string(path.rel()) });
|
{ "-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`
|
// Pause the logger to allow for user input (such as a gpg passphrase) in `git commit`
|
||||||
logger->pause();
|
logger->pause();
|
||||||
Finally restoreLogger([]() { logger->resume(); });
|
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, "commit", std::string(path.rel()), "-m", *commitMsg });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct RepoInfo
|
struct RepoInfo
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue