threads / patch / 20977

patchUpdate the usage bundle string.

Subject: [PATCH] Update the usage bundle string.

## tl;dr

5 messages between Sep 16, 2009 and Sep 17, 2009. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Thiago Farina· Sep 16, 2009, 21:20 UTC · lore

Currently the usage bundle string is not well formatted. Now it is formatted and the user can read the string much more easily.

Signed-off-by: Thiago Farina <tfransosi@gmail.com>
---
 builtin-bundle.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
Show changes to builtin-bundle.c +9 −3
diff --git a/builtin-bundle.c b/builtin-bundle.c
index 9b58152..2e98907 100644
--- a/builtin-bundle.c
+++ b/builtin-bundle.c
@@ -11,6 +11,12 @@
 
 static const char *bundle_usage="git bundle (create <bundle> <git rev-list args> | verify <bundle> | list-heads <bundle> [refname]... | unbundle <bundle> [refname]... )";
 
+static const char builtin_bundle_usage[] = "\
+  git bundle create <file> <git-rev-list args>\n\
+  git bundle verify <file>\n\
+  git bundle list-heads <file> [refname...]\n\
+  git bundle unbundle <file> [refname...]";
+
 int cmd_bundle(int argc, const char **argv, const char *prefix)
 {
 	struct bundle_header header;
@@ -19,8 +25,8 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
 	int bundle_fd = -1;
 	char buffer[PATH_MAX];
 
-	if (argc < 3)
-		usage(bundle_usage);
+  if (argc < 3)
+		usage(builtin_bundle_usage);
 
 	cmd = argv[1];
 	bundle_file = argv[2];
@@ -59,5 +65,5 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
 		return !!unbundle(&header, bundle_fd) ||
 			list_bundle_refs(&header, argc, argv);
 	} else
-		usage(bundle_usage);
+		usage(builtin_bundle_usage);
 }
-- 
1.6.5.rc0.dirty
Johannes Sixt· Sep 17, 2009, 06:12 UTC · re: Thiago Farina · lore

Re: [PATCH] Update the usage bundle string.

Thiago Farina schrieb:
> @@ -11,6 +11,12 @@
>  
>  static const char *bundle_usage="git bundle (create <bundle> <git rev-list args> | verify <bundle> | list-heads <bundle> [refname]... | unbundle <bundle> [refname]... )";
Is this variable still used? Shouldn't it be removed?
Show 5 quoted lines
> +static const char builtin_bundle_usage[] = "\
> +  git bundle create <file> <git-rev-list args>\n\
> +  git bundle verify <file>\n\
> +  git bundle list-heads <file> [refname...]\n\
> +  git bundle unbundle <file> [refname...]";

You indent the usage text. Do other commands do that, too? If you resend, it may be worth using this style:

static const char builtin_bundle_usage[] =
	"git bundle create <file> <git-rev-list args>\n"
	"git bundle verify <file>\n"
...
i.e. not to use backslash-at-eol.
> -	if (argc < 3)
> -		usage(bundle_usage);
> +  if (argc < 3)
> +		usage(builtin_bundle_usage);
This re-indentation is an accident, isn't it?
-- Hannes
Thiago Farina· Sep 17, 2009, 15:56 UTC · re: Johannes Sixt · lore

Re: [PATCH] Update the usage bundle string.

On Thu, Sep 17, 2009 at 3:12 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 6 quoted lines
> Thiago Farina schrieb:
>> @@ -11,6 +11,12 @@
>>
>>  static const char *bundle_usage="git bundle (create <bundle> <git rev-list args> | verify <bundle> | list-heads <bundle> [refname]... | unbundle <bundle> [refname]... )";
>
> Is this variable still used? Shouldn't it be removed?

Yeah it should be removed, I did this in the third email that I sent. To send another revision of the patch I'm doing this: $ git commit <filename> --amend $ git format-patch -1 --subject-prefix "Patch vN" But I'm not sure if this is the correct away to send another set of changes of the same patch. Is right?

Show 17 quoted lines
>
>> +static const char builtin_bundle_usage[] = "\
>> +  git bundle create <file> <git-rev-list args>\n\
>> +  git bundle verify <file>\n\
>> +  git bundle list-heads <file> [refname...]\n\
>> +  git bundle unbundle <file> [refname...]";
>
> You indent the usage text. Do other commands do that, too? If you resend,
> it may be worth using this style:
>
> static const char builtin_bundle_usage[] =
>        "git bundle create <file> <git-rev-list args>\n"
>        "git bundle verify <file>\n"
> ...
>
> i.e. not to use backslash-at-eol.
>

Sure, I will update it to use this style. There is another usage string that uses backslash-at-eol, it is in builtin-pack-objecs.c . Should I update this string too?

Show 6 quoted lines
>> -     if (argc < 3)
>> -             usage(bundle_usage);
>> +  if (argc < 3)
>> +             usage(builtin_bundle_usage);
>
> This re-indentation is an accident, isn't it?

Was an accident, sorry about that. I configured my editor to use 2 spaces per indent, tab size 2 and expand tabs to spaces. Git uses 4 spaces per indent and tab size 4?

>
> -- Hannes
>
>
Matthieu Moy· Sep 17, 2009, 16:04 UTC · re: Johannes Sixt · lore

Re: [PATCH] Update the usage bundle string.

Johannes Sixt <j.sixt@viscovery.net> writes:
Show 14 quoted lines
> Thiago Farina schrieb:
>
>> +static const char builtin_bundle_usage[] = "\
>> +  git bundle create <file> <git-rev-list args>\n\
>> +  git bundle verify <file>\n\
>> +  git bundle list-heads <file> [refname...]\n\
>> +  git bundle unbundle <file> [refname...]";
>
> You indent the usage text. Do other commands do that, too? If you resend,
> it may be worth using this style:
>
> static const char builtin_bundle_usage[] =
> 	"git bundle create <file> <git-rev-list args>\n"
> 	"git bundle verify <file>\n"
I like aligned usage strings, like:
$ git stash -h
Usage: git stash list [<options>]
   or: git stash show [<stash>]
   or: git stash drop [-q|--quiet] [<stash>]
   or: git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
   or: git stash branch <branchname> [<stash>]
   or: git stash [save [-k|--keep-index] [-q|--quiet] [<message>]]
   or: git stash clear
or
$ git branch -h |& head -n 4
usage: git branch [options] [-r | -a] [--merged | --no-merged]
   or: git branch [options] [-l] [-f] <branchname> [<start-point>]
   or: git branch [options] [-r] (-d | -D) <branchname>
   or: git branch [options] (-m | -M) [<oldbranch>] <newbranch>
but Git isn't very consistant here:
$ git bisect -h |& head  -n 6
Usage: git bisect [help|start|bad|good|skip|next|reset|visualize|replay|log|run]
git bisect help
        print this long help message.
git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
        reset bisect state and start bisection.

-- Matthieu Moy http://www-verimag.imag.fr/~moy/

Thiago Farina· Sep 17, 2009, 16:16 UTC · re: Matthieu Moy · lore

Re: [PATCH] Update the usage bundle string.

On Thu, Sep 17, 2009 at 1:04 PM, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:

Show 36 quoted lines
> Johannes Sixt <j.sixt@viscovery.net> writes:
>
>> Thiago Farina schrieb:
>>
>>> +static const char builtin_bundle_usage[] = "\
>>> +  git bundle create <file> <git-rev-list args>\n\
>>> +  git bundle verify <file>\n\
>>> +  git bundle list-heads <file> [refname...]\n\
>>> +  git bundle unbundle <file> [refname...]";
>>
>> You indent the usage text. Do other commands do that, too? If you resend,
>> it may be worth using this style:
>>
>> static const char builtin_bundle_usage[] =
>>       "git bundle create <file> <git-rev-list args>\n"
>>       "git bundle verify <file>\n"
>
> I like aligned usage strings, like:
>
> $ git stash -h
> Usage: git stash list [<options>]
>   or: git stash show [<stash>]
>   or: git stash drop [-q|--quiet] [<stash>]
>   or: git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
>   or: git stash branch <branchname> [<stash>]
>   or: git stash [save [-k|--keep-index] [-q|--quiet] [<message>]]
>   or: git stash clear
>
> or
>
> $ git branch -h |& head -n 4
> usage: git branch [options] [-r | -a] [--merged | --no-merged]
>   or: git branch [options] [-l] [-f] <branchname> [<start-point>]
>   or: git branch [options] [-r] (-d | -D) <branchname>
>   or: git branch [options] (-m | -M) [<oldbranch>] <newbranch>
>
I like and prefer this style too. I can use it in my patch, like:
$ git bundle -h
usage: git bundle create <file> <git-rev-list args>
  or: git bundle verify <file>
  or: git bundle list-heads <file> [refname...]
  or: git bundle unbundle <file> [refname...]
instead of:
usage: git bundle create <file> <git-rev-list args>
          git bundle verify <file>
          git bundle list-heads <file> [refname...]
          git bundle unbundle <file> [refname...]
Show 14 quoted lines
> but Git isn't very consistant here:
>
> $ git bisect -h |& head  -n 6
> Usage: git bisect [help|start|bad|good|skip|next|reset|visualize|replay|log|run]
>
> git bisect help
>        print this long help message.
> git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
>        reset bisect state and start bisection.
>
> --
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/
>

← back to recent threads