From 2bbdaf0b19066ea1764e8d5810c2b250dbf0a850 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 23 Jun 2024 15:10:31 +0200 Subject: libfetchers: write git commit message to tempfile we want to remove runProgram's ability to provide stdin to a process because the concurrency issues of handling both stdin and stdout are much more pronounced once runProgram returns not is collected output but a source. this is possible in the current c++ framework, however it isn't necessary in almost all cases (as demonstrated by only this single user existing) and in much better handled with a proper async concurrency model that lets the caller handle both at the same time. Change-Id: I29da1e1ad898d45e2e33a7320b246d5003e7712b --- src/libfetchers/git.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index 0cb826075..f2d577914 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -396,12 +396,15 @@ struct GitInputScheme : InputScheme if (commitMsg) { + auto [_fd, msgPath] = createTempFile("nix-msg"); + AutoDelete const _delete{msgPath}; + writeFile(msgPath, *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", *root, "--git-dir", gitDir, "commit", std::string(path.rel()), "-F", "-" }, - *commitMsg); + { "-C", *root, "--git-dir", gitDir, "commit", std::string(path.rel()), "-F", msgPath }); } } } -- cgit v1.2.3