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.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 935EB1F5AE for ; Fri, 23 Apr 2021 21:08:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244163AbhDWVId (ORCPT ); Fri, 23 Apr 2021 17:08:33 -0400 Received: from mail-ed1-f53.google.com ([209.85.208.53]:33517 "EHLO mail-ed1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244168AbhDWVIB (ORCPT ); Fri, 23 Apr 2021 17:08:01 -0400 Received: by mail-ed1-f53.google.com with SMTP id cq11so15254388edb.0 for ; Fri, 23 Apr 2021 14:07:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vzD7tOfXzrIp/NVtlsJzVV/FS83KB2tqD5Ws2kg+poo=; b=cG4y+c8O9XWRqIOBswV5l/NiZkEYB+HlMNGKgFbDjYqgmqN5in3KE6yU7qrQd7Yddv J//iVGDMpn8mf9K7K9935143U0hcOsxV3ENWASraY/lw/1kStE4q2uTInnT2xSTmKIjg aYTKtLfxdqSQyCj9GPpvILC1QG+88dqjYt68fI9kNOber0gBROZkHgCFEKtFD1L6Kavh rwy0QWsds5z9V9cQphPS0F3P+OUcPgWQU7s4L9SbJxuCK9j8Rbm7YfZs0KxsFOdiF0/P ReaUUOKzmnzTZDE+DEwzS2XXBTEkyeuQpCdk4nkMWRcaR13IpCcFKLJekUXT1pd8ap/j lv4w== X-Gm-Message-State: AOAM530DgPzDiM1t/GrfFr7S0ys3Hi69jt58J4Dld2VqEf77w9y2zHiI eMdAJkyNsO12ogu/hWUJcnHT9D9LID98FJNjmPE= X-Google-Smtp-Source: ABdhPJw4KrI8Led0oxKm2qGKu+UbN3rmTmBXLR+KWr7KcdI3driVypGNYfhGrt98rGx7mtm66hPnodEWuqnu0/Troao= X-Received: by 2002:a05:6402:145:: with SMTP id s5mr6661008edu.221.1619212043007; Fri, 23 Apr 2021 14:07:23 -0700 (PDT) MIME-Version: 1.0 References: <20210423194230.1388945-1-lukeshu@lukeshu.com> <20210423194230.1388945-25-lukeshu@lukeshu.com> In-Reply-To: <20210423194230.1388945-25-lukeshu@lukeshu.com> From: Eric Sunshine Date: Fri, 23 Apr 2021 17:07:12 -0400 Message-ID: Subject: Re: [PATCH 24/30] subtree: don't let debug and progress output clash To: Luke Shumaker Cc: 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?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , Roger L Strain , Techlive Zheng , Luke Shumaker Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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/ > 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). > 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 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.