Merge pull request #9445 from NixOS/allow-input-in-git-commit

Allow user input in `git commit`

(cherry picked from commit 43fb39ca29a0b054a4c18623520c496d27c57192)
Change-Id: I13bd4c007234ee2133289c68ef8ab2eae4def78a
This commit is contained in:
eldritch horrors 2024-03-04 06:01:09 +01:00
parent 9981c714f6
commit cba87025f8

View file

@ -7,6 +7,8 @@
#include "pathlocks.hh" #include "pathlocks.hh"
#include "util.hh" #include "util.hh"
#include "git.hh" #include "git.hh"
#include "logging.hh"
#include "finally.hh"
#include "fetch-settings.hh" #include "fetch-settings.hh"
@ -378,6 +380,9 @@ struct GitInputScheme : InputScheme
runProgram("git", true, runProgram("git", true,
{ "-C", *sourcePath, "--git-dir", gitDir, "add", "--intent-to-add", "--", std::string(file) }); { "-C", *sourcePath, "--git-dir", gitDir, "add", "--intent-to-add", "--", std::string(file) });
// Pause the logger to allow for user input (such as a gpg passphrase) in `git commit`
logger->pause();
Finally restoreLogger([]() { logger->resume(); });
if (commitMsg) if (commitMsg)
runProgram("git", true, runProgram("git", true,
{ "-C", *sourcePath, "--git-dir", gitDir, "commit", std::string(file), "-m", *commitMsg }); { "-C", *sourcePath, "--git-dir", gitDir, "commit", std::string(file), "-m", *commitMsg });