diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2023-02-04 14:01:37 +0000 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2023-02-04 15:41:12 +0000 |
commit | 4c0cc9b00b556c3bbf56c8370c4f5e3b319aff5e (patch) | |
tree | 339469cd1988bddd7041db3bdbe0bbec7d42cd89 | |
parent | 7a299b81c55610de8801cd81f4bd512050d3539c (diff) |
Suppress unwanted messages from git-rebase.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rw-r--r-- | Debian/Dgit.pm | 17 | ||||
-rwxr-xr-x | dgit | 3 |
2 files changed, 17 insertions, 3 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index f61185d..6168b19 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -55,7 +55,8 @@ BEGIN { must_getcwd executable_on_path waitstatusmsg failedcmd_waitstatus failedcmd_report_cmd failedcmd - runcmd shell_cmd cmdoutput cmdoutput_errok + runcmd runcmd_quieten + shell_cmd cmdoutput cmdoutput_errok @git git_rev_parse changedir_git_toplevel git_cat_file git_get_ref git_get_symref git_for_each_ref @@ -397,6 +398,20 @@ sub shell_cmd { return qw(sh -ec), $first_shell.'; exec "$@"', 'x', @cmd; } +# Runs the command in @_, but capturing its stdout and stderr. +# Prints those to our stderr only if the command fails. +sub runcmd_quieten { + debugcmd "+",@_; + $!=0; $?=-1; + my @real_cmd = shell_cmd <<'END', @_; + set +e; output=$("$@" 2>&1); rc=$?; set -e + if [ $rc = 0 ]; then exit 0; fi + printf >&2 "%s\n" "$output" + exit $rc +END + failedcmd @_ if system @real_cmd; +} + sub cmdoutput_errok { confess Dumper(\@_)." ?" if grep { !defined } @_; local $printdebug_when_debuglevel = $debugcmd_when_debuglevel; @@ -2794,8 +2794,7 @@ END if ($use_absurd) { # Perhaps we should be using git-filter-branch, # but that's really considerably more awkward. - # TODO: even --quiet still leave some stderr output ;-/ - runcmd + runcmd_quieten @git, qw(rebase --keep-empty --allow-empty-message --onto unpa~1 unpa); } |