All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] usage_with_options: omit double new line on empty option list
Date: Fri, 25 Aug 2017 10:21:27 -0700	[thread overview]
Message-ID: <xmqq378ftvfs.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqq7exrtvl1.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Fri, 25 Aug 2017 10:18:18 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Stefan Beller <sbeller@google.com> 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 [<options>] <path> [<branch>]
>>        or: git worktree list [<options>]
>>        or: git worktree lock [<options>] <path>
>>        or: git worktree prune [<options>]
>>        or: git worktree unlock <path>
>>
>>
>>     $
>>
>> 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.
>>
>> Only print one new line after the usage string if the option list is empty.
>
> Good find.  Shouldn't the last word in the sentence "non-empty", though?

Ah, the "do this" part was hard to understand and I misread it.  I
thought you were saying "only give a blank if we have something that
need to be separated from the stuff above".

So what you wrote above is not incorrect per-se, but I think it is
prone to be misunderstood.

>
>>
>> Signed-off-by: Stefan Beller <sbeller@google.com>
>> ---
>>  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++) {

  parent reply	other threads:[~2017-08-25 17:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25 16:48 [PATCH] usage_with_options: omit double new line on empty option list Stefan Beller
2017-08-25 17:18 ` Junio C Hamano
2017-08-25 17:19   ` Stefan Beller
2017-08-25 17:21   ` Junio C Hamano [this message]
2017-08-25 17:31 ` Junio C Hamano
     [not found] <xmqqy3q7sge2.fsf@gitster.mtv.corp.google.com/>
2017-08-25 19:28 ` Stefan Beller
2017-08-25 20:27   ` Junio C Hamano
2017-08-25 21:06     ` Stefan Beller
2017-08-25 21:17       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq378ftvfs.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.