From 1884110885479abb7977b8d43024aa7a38d2e628 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 5 Dec 2018 23:09:49 +0300 Subject: Prevent git-reset from messing up pkg-{build,checkout} output --- bpkg/fetch-git.cxx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/bpkg/fetch-git.cxx b/bpkg/fetch-git.cxx index 733c8fe..3986e1d 100644 --- a/bpkg/fetch-git.cxx +++ b/bpkg/fetch-git.cxx @@ -1704,14 +1704,21 @@ namespace bpkg // if we produce any untracked files in the tree between checkouts down // the road. // - if (!run_git ( - co, - co.git_option (), - "-C", dir, - "reset", - "--hard", - verb < 2 ? opt ("-q") : nullopt, - commit)) + // Note that the `git reset --hard` command running non-quiet prints the + // `HEAD is now at...` message to stdout (which is a deliberate behavior; + // see reply to the 631ae70d-9b5f-613d-5b6f-5064d548a894@codesynthesis.com + // issue report for details). To avoid messing up bpkg output we will + // redirect git stdout to stderr. + // + process pr (start_git (co, + 2 /* stdout */, 2 /* stderr */, + co.git_option (), + "-C", dir, + "reset", + "--hard", + verb < 2 ? opt ("-q") : nullopt, + commit)); + if (!pr.wait ()) fail << "unable to reset to " << commit << endg; if (!run_git ( -- cgit v1.1