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.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 10B74208DB for ; Fri, 25 Aug 2017 17:31:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757371AbdHYRbw (ORCPT ); Fri, 25 Aug 2017 13:31:52 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:54507 "EHLO sasl.smtp.pobox.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755114AbdHYRbv (ORCPT ); Fri, 25 Aug 2017 13:31:51 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 3A350957EE; Fri, 25 Aug 2017 13:31:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=jNIXM86XAoH1ZLbLg/08C0xpzUU=; b=ain2qb aXON4ASl0964IdOd9qGyZMaOoBbs+liC1zVOlneV0Hpzu/KIC11MkX+w1HX1DJbz 4SOk9tBDiIafx+YGFd8sGM4xzHTcxtpPGceLkfgHlbedCMCdsW1YwfaEvHfJev4s FJdlc9MjTo9dD9ckqqMfA3YkanhweWM22dZ84= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=qeeuqzykBBTEba29s36KXvp4ZSq8U1bE dgzKhZMxqpZw/dr8u//kA2k5cCXr/USVvP14HQRp0xJxcAscv+GgBG2pbU/brJuX 7J/BXFPUb3ed1Na7Nz5E/RwMoEqeyAuNEJ79+dx1cYT02SN8zYMqWnec/4PkgJIt oLahpK4iLxM= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 32E27957ED; Fri, 25 Aug 2017 13:31:51 -0400 (EDT) Received: from pobox.com (unknown [104.132.0.95]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 73B9B957EA; Fri, 25 Aug 2017 13:31:50 -0400 (EDT) From: Junio C Hamano To: Stefan Beller Cc: git@vger.kernel.org Subject: Re: [PATCH] usage_with_options: omit double new line on empty option list References: <20170825164837.30118-1-sbeller@google.com> Date: Fri, 25 Aug 2017 10:31:49 -0700 In-Reply-To: <20170825164837.30118-1-sbeller@google.com> (Stefan Beller's message of "Fri, 25 Aug 2017 09:48:37 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 47395B6E-89BB-11E7-9E7C-9D2B0D78B957-77302942!pb-smtp2.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Stefan Beller writes: > Currently the worktree command gives its usage, when no subcommand is > given. However there are no general options, all options are related to > the subcommands itself, such that: > > $ git worktree > usage: git worktree add [] [] > or: git worktree list [] > or: git worktree lock [] > or: git worktree prune [] > or: git worktree unlock > > > $ > > Note the two empty lines at the end of the usage string. This is because > the toplevel usage is printed with an empty options list. I have this feeling that this patch may not be sufficient. The reason for the first blank line is because we unconditionally emit one, expecting that we would have a list of options to show and want to separate the usage from that list, and the fix in this patch is correct---it is the right way to suppress it. But why do we need the second blank line in this case? There is a similar unconditional LF near the end of this function. Is somebody else (other than usage_with_options() which will exit immeidately) calls this function and expects to say something more after what this function said, and is this extra blank line at the end is to prepare for that caller? > Only print one new line after the usage string if the option list is empty. > > Signed-off-by: Stefan Beller > --- > parse-options.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/parse-options.c b/parse-options.c > index 0dd9fc6a0d..1307c82861 100644 > --- a/parse-options.c > +++ b/parse-options.c > @@ -603,7 +603,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx, > usagestr++; > } > > - if (opts->type != OPTION_GROUP) > + if (opts->type != OPTION_GROUP && opts->type != OPTION_END) > fputc('\n', outfile); > > for (; opts->type != OPTION_END; opts++) {