Re: [PATCH 3/3] builtins: check for startup_info->help, print and exit early
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Oct 19, 2010, 17:55 UTC
- Message-ID
- <20101019175520.GD25139@burratino>
- In-Reply-To
- <1287495320-27278-3-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
Show 12 quoted lines
> --- a/builtin/branch.c > +++ b/builtin/branch.c > @@ -667,6 +667,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix) > OPT_END(), > }; > > + if (startup_info->help) > + usage_with_options(builtin_branch_usage, options); > + > git_config(git_branch_config, NULL); > > if (branch_use_color == -1)
One has to work hard to trigger this one.
git init foo cd foo >.git/refs/heads/master git branch -h
Produces:
fatal: Failed to resolve HEAD as a valid ref.
Show 12 quoted lines
> --- a/builtin/checkout-index.c > +++ b/builtin/checkout-index.c > @@ -241,6 +241,9 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) > OPT_END() > }; > > + if (startup_info->help) > + usage_with_options(builtin_checkout_index_usage, builtin_checkout_index_options); > + > git_config(git_default_config, NULL); > state.base_dir = ""; > prefix_length = prefix ? strlen(prefix) : 0;
git init foo cd foo >.git/index git checkout-index -h
Produces:
fatal: index file smaller than expected
> --- a/builtin/commit.c > +++ b/builtin/commit.c
I'm stopping here. But maybe some test cases like this would make the series clearer.
Hope that helps, Jonathan