git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Simplify usage string printing

From
Jonas Fonseca <fonseca@diku.dk>
Date
Oct 14, 2007, 14:01 UTC
Message-ID
<20071014140116.GA20970@diku.dk>
In-Reply-To
<1192282153-26684-10-git-send-email-madcoder@debian.org>
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
 builtin-branch.c     |    1 -
 builtin-update-ref.c |    1 -
 parse-options.c      |    2 +-
 3 files changed, 1 insertions(+), 3 deletions(-)
 Pierre Habouzit <madcoder@debian.org> wrote Sat, Oct 13, 2007:
 > Signed-off-by: Pierre Habouzit <madcoder@debian.org>
 > ---
 >  builtin-update-ref.c |   71 +++++++++++++++++++++-----------------------------
 >  1 files changed, 30 insertions(+), 41 deletions(-)
 > 
 > diff --git a/builtin-update-ref.c b/builtin-update-ref.c
 > index fe1f74c..eafb642 100644
 > --- a/builtin-update-ref.c
 > +++ b/builtin-update-ref.c
 > @@ -1,59 +1,48 @@
 >  #include "cache.h"
 >  #include "refs.h"
 >  #include "builtin.h"
 > +#include "parse-options.h"
 >  
 > -static const char git_update_ref_usage[] =
 > -"git-update-ref [-m <reason>] (-d <refname> <value> | [--no-deref] <refname> <value> [<oldval>])";
 > +static const char * const git_update_ref_usage[] = {
 > +	"",
 > +	"git-update-ref [options] -d <refname> <oldval>",
 > +	"git-update-ref [options]    <refname> <newval> [<oldval>]",
 > +	NULL
 > +};
 How about something like this to get rid of these empty strings
 that look strange?
	> ./git update-ref -h
	usage: git-update-ref [options] -d <refname> <oldval>
	   or: git-update-ref [options]    <refname> <newval> [<oldval>]
	    -m <reason>           reason of the update
	    -d                    deletes the reference
	    --no-deref            update <refname> not the one it points to
diff --git a/builtin-branch.c b/builtin-branch.c
index fbf983e..d7c4657 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -14,7 +14,6 @@
 #include "parse-options.h"
 
 static const char * const builtin_branch_usage[] = {
-	"",
 	"git-branch [options] [-r | -a]",
 	"git-branch [options] [-l] [-f] <branchname> [<start-point>]",
 	"git-branch [options] [-r] (-d | -D) <branchname>",
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index d66d9b5..0cd7817 100644
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
@@ -4,7 +4,6 @@
 #include "parse-options.h"
 
 static const char * const git_update_ref_usage[] = {
-	"",
 	"git-update-ref [options] -d <refname> <oldval>",
 	"git-update-ref [options]    <refname> <newval> [<oldval>]",
 	NULL
diff --git a/parse-options.c b/parse-options.c
index c45bb9b..b1d9608 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -181,7 +181,7 @@ void usage_with_options(const char * const *usagestr,
 {
 	fprintf(stderr, "usage: %s\n", *usagestr);
 	while (*++usagestr)
-		fprintf(stderr, "    %s\n", *usagestr);
+		fprintf(stderr, "   or: %s\n", *usagestr);
 
 	if (opts->type != OPTION_GROUP)
 		fputc('\n', stderr);
-- 
1.5.3.4.1166.gf076

-- 
Jonas Fonseca
Previous: Pierre HabouzitNext: Pierre Habouzit
Message 39 of 42 in “[RFC] CLI option parsing and usage generation for porcelains”
  1. Pierre HabouzitOct 13, 2007
  2. Wincent ColaiutaOct 13, 2007
  3. Eric WongOct 14, 2007
  4. Pierre HabouzitOct 14, 2007
  5. parse-options: Allow abbreviated options when unambiguousJohannes Schindelin, Oct 14, 2007
  6. Johannes SchindelinOct 14, 2007
  7. Pierre HabouzitOct 14, 2007
  8. Eric WongOct 14, 2007
  9. Johannes SchindelinOct 14, 2007
  10. Eric WongOct 14, 2007
  11. git-svn and submodules, was Re: [PATCH] parse-options: Allow abbreviated options when unambiguousJohannes Schindelin, Oct 14, 2007
  12. Benoit SIGOUREOct 15, 2007
  13. Andreas EricssonOct 15, 2007
  14. Benoit SIGOUREOct 15, 2007
  15. David KastrupOct 15, 2007
  16. Benoit SIGOUREOct 15, 2007
  17. Andreas EricssonOct 15, 2007
  18. Karl HasselströmOct 15, 2007
  19. .gitignore and svn:ignore [WAS: git-svn and submodules]Chris Shoemaker, Oct 15, 2007
  20. Eric WongOct 16, 2007
  21. Karl HasselströmOct 16, 2007
  22. Chris ShoemakerOct 16, 2007
  23. Linus TorvaldsOct 15, 2007
  24. Performance issue with excludes (was: Re: git-svn and submodules)Benoit SIGOURE, Oct 15, 2007
  25. Linus TorvaldsOct 15, 2007
  26. Benoit SIGOUREOct 15, 2007
  27. Linus TorvaldsOct 15, 2007
  28. Benoit SIGOUREOct 15, 2007
  29. Johannes SchindelinOct 13, 2007
  30. Pierre HabouzitOct 13, 2007
  31. Johannes SchindelinOct 13, 2007
  32. Pierre HabouzitOct 13, 2007
  33. Alex RiesenOct 13, 2007
  34. Pierre HabouzitOct 13, 2007
  35. Alex RiesenOct 13, 2007
  36. Pierre HabouzitOct 13, 2007
  37. Alex RiesenOct 13, 2007
  38. Pierre HabouzitOct 14, 2007
  39. Simplify usage string printingJonas Fonseca, Oct 14, 2007
  40. Pierre HabouzitOct 14, 2007
  41. Update manpages to reflect new short and long option aliasesJonas Fonseca, Oct 14, 2007
  42. Pierre HabouzitOct 14, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.