From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 826B01F5AE for ; Sat, 24 Apr 2021 00:46:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232781AbhDXApX (ORCPT ); Fri, 23 Apr 2021 20:45:23 -0400 Received: from mav.lukeshu.com ([104.207.138.63]:36092 "EHLO mav.lukeshu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232106AbhDXApV (ORCPT ); Fri, 23 Apr 2021 20:45:21 -0400 Received: from lukeshu-dw-thinkpad (unknown [IPv6:2601:281:8200:26:4e34:88ff:fe48:5521]) by mav.lukeshu.com (Postfix) with ESMTPSA id 6E91C80590; Fri, 23 Apr 2021 20:44:41 -0400 (EDT) Date: Fri, 23 Apr 2021 18:44:40 -0600 Message-ID: <87v98ca4uf.wl-lukeshu@lukeshu.com> From: Luke Shumaker To: Eric Sunshine Cc: Luke Shumaker , Git List , Avery Pennarun , Charles Bailey , Danny Lin , "David A . Greene" , David Aguilar , Jakub Suder , James Denholm , Jeff King , Jonathan Nieder , Junio C Hamano , =?UTF-8?B?Tmd1?= =?UTF-8?B?eeG7hW4g?= =?ISO-8859-1?Q?Th=E1i_?= =?UTF-8?B?Tmfhu41j?= Duy , Roger L Strain , Techlive Zheng , Luke Shumaker Subject: Re: [PATCH 24/30] subtree: don't let debug and progress output clash In-Reply-To: References: <20210423194230.1388945-1-lukeshu@lukeshu.com> <20210423194230.1388945-25-lukeshu@lukeshu.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, 23 Apr 2021 15:07:12 -0600, Eric Sunshine wrote: > > On Fri, Apr 23, 2021 at 3:43 PM Luke Shumaker wrote: > > Currently, debug output (triggered by passing '-d') and progress output > > stomp on eachother. The debug output is just streamed as lines to > > s/eachother/each other/ Ack. > > stderr, and the progress output is sent to stderr as '%s\r'. It is > > difficult to distinguish between the debug output and a progress line. > > When writing to a terminal the debug lines hide progress lines. > > > > So, when '-d' has been passed, spit out progress as 'progress: %s\n', > > instead of as '%s\r', so that it can be detected, and so that the debug > > lines don't overwrite the progress when written to a terminal. > > Makes perfect sense when output is to a terminal, though might be > annoying for the person who redirects stderr to a file. Just idly > wondering if it makes sense to take that case into consideration... > (but maybe it doesn't matter much when someone is working at debugging > a problem). The '%s\r' isn't really useful when written to a file, so this change is useful in the file case too. I'll add a comment and update the commit-message. > > Signed-off-by: Luke Shumaker > > --- > > diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh > > @@ -53,7 +53,12 @@ debug () { > > progress () { > > if test -z "$GIT_QUIET" > > then > > - printf "%s\r" "$*" >&2 > > + if test -n "$arg_debug" > > + then > > + printf "progress: %s\n" "$*" >&2 > > + else > > + printf "%s\r" "$*" >&2 > > + fi > > fi > > } > > Subjective (not necessarily worth changing): An `echo` would suffice > in place of `printf "...\n"`: > > echo "progress: $*" >&2 echo would suffice, but I prefer the printf. > It _might_ be worthwhile to have an in-code comment here explaining > why progress() behaves differently in debug mode, especially if the > reader is confused about why one case explicitly emits "progress:" and > the other doesn't. Adding a comment is a good idea, I'll do that. -- Happy hacking, ~ Luke Shumaker