From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.8 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MALFORMED_FREEMAIL,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 6F6281F858 for ; Tue, 2 Aug 2016 08:09:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754714AbcHBIJR (ORCPT ); Tue, 2 Aug 2016 04:09:17 -0400 Received: from mout.gmx.net ([212.227.15.19]:61040 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751175AbcHBIIn (ORCPT ); Tue, 2 Aug 2016 04:08:43 -0400 Received: from virtualbox ([37.24.142.100]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0Lug8u-1b4CLp1CRk-00zlv3; Tue, 02 Aug 2016 10:01:45 +0200 Date: Tue, 2 Aug 2016 10:01:42 +0200 (CEST) From: Johannes Schindelin X-X-Sender: virtualbox@virtualbox To: Junio C Hamano cc: git@vger.kernel.org, Eric Sunshine , Jeff King , Johannes Sixt , Duy Nguyen , =?UTF-8?Q?Jakub_Nar=C4=99bski?= Subject: Re: [PATCH v5 14/16] merge-recursive: offer an option to retain the output in 'obuf' In-Reply-To: Message-ID: References: <0ba371955b9a4aeb752ce08fc22bbd8171f413c4.1469547160.git.johannes.schindelin@gmx.de> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K0:sU8+8ZmRibL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@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Junio, On Mon, 1 Aug 2016, Junio C Hamano wrote: > Johannes Schindelin writes: > > >> I actually now see how this would work well for "reason 2)". If a > >> caller wants to run the function and wants to pretend as if it did > >> not run anything when it failed, for example, using this to spool all > >> output and error to a strbuf and discard it when the function returns > >> an error, and emit the spooled output to standard output and standard > >> error in the order the lines were collected when the function returns > >> a success, would be a good way to do so. > > > > That is actually the exact opposite of the intended usage: when any > > `pick` in an interactive rebase succeeds, its output is discarded so > > as not to bother the user. We show the complete output only when it > > fails. > > Oh, it makes sense, too, to show the output only when there is an error. Thanks ;-) > But in that case, there would be both messages meant for the > standard output and also meant for the standard error, and we need > some way to make sure they go to the right channel. Not necessarily. Let's have a look at our existing code in git-rebase.sh: output () { case "$verbose" in '') output=$("$@" 2>&1 ) status=$? test $status != 0 && printf "%s\n" "$output" return $status ;; *) "$@" ;; esac } This incredibly well-named function (, my fault: dfa49f3 (Shut "git rebase -i" up when no --verbose was given, 2007-07-23)) accumulates all output, both stdout and stderr, and shows it only in case of an error. Crucially, *all* output goes to stdout. No distinction is being made between stdout and stderr. This is the existing behavior of rebase -i. > I however do not think an array of is the only > way to achieve that. We can get away by a single strbuf that > accumulates all output() that we have seen so far, i.e. "we only > accumulate output() and ignore flush() as long as what we see are > only from output()" mode. > > Then the err() routine operating under this new mode can show what > has been accumulated to the standard output (because with this tweak > I am outlining here, by definition, the strbuf will only keep the > output() material and not err() things), show the err() message, and > switch back to the normal "we accumulate output() and honor flush()" > mode. Of course, when we are doing multiple rounds, the mode must > be reset to "accumulate output and ignore flush" mode at the > beginning of each rouhd. > > That would give us "silence if there is no error, but if we are > showing error, show them to the standard error, while giving > non-error message to the standard output". It all makes sense what you say. In case you want to preserve the channel in some future modification. However, I am right now most concerned about keeping existing behavior as faithfully as possible (with the exception of execution speed, which I want to improve dramatically). As such, it would be a serious mistake to implement that mode and use it in the rebase--helper: it would very likely cause regressions in existing scripts, probably even my own. So I do understand your concern, and I agree that it would make for a fine design, in a different context than this patch series. Ciao, Dscho