git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usage_with_options: omit double new line on empty option list
@ 2017-08-25 16:48 Stefan Beller
  2017-08-25 17:18 ` Junio C Hamano
  2017-08-25 17:31 ` Junio C Hamano
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Beller @ 2017-08-25 16:48 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller

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.

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++) {
-- 
2.14.0.rc0.3.g6c2e499285


^ permalink raw reply related	[flat|nested] 9+ messages in thread
[parent not found: <xmqqy3q7sge2.fsf@gitster.mtv.corp.google.com/>]

end of thread, other threads:[~2017-08-25 21:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).