From: Junio C Hamano Date: Fri, 25 Aug 2017 17:21:27 GMT Subject: Re: [PATCH] usage_with_options: omit double new line on empty option list Message-ID: In-Reply-To: Junio C Hamano writes: > 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. >> >> 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 >> --- >> 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++) {