Re: [PATCH v2 1/2] rev-parse: add option --is-well-formed-git-dir [path]
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 11, 2011, 23:34 UTC
- Message-ID
- <7v62m3plnx.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1312831022-12868-2-git-send-email-iveqy@iveqy.com>
Fredrik Gustafsson <iveqy@iveqy.com> writes:
Show 11 quoted lines
> diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
> index 4c19f84..82342b3 100644
> --- a/builtin/rev-parse.c
> +++ b/builtin/rev-parse.c
> @@ -455,6 +455,14 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
> unsigned char sha1[20];
> const char *name = NULL;
>
> + if (argc > 2 && !strcmp(argv[1], "--is-well-formed-git-dir")) {
> + const char *gitdir = resolve_gitdir(argv[2]);
> + if(!gitdir)(style) SP immediately after "if".
> + die("not a gitdir");die("not a gitdir '%s'", argv[2]) perhaps?Show 6 quoted lines
> + puts(gitdir);
> + return 0;
> + }
> +
> if (argc > 1 && !strcmp("--parseopt", argv[1]))
> return cmd_parseopt(argc - 1, argv + 1, prefix);When adding a new element to existing list of other similar things, I would prefer to see it added at the end (in this case, just before "-h", which is kind of special), unless there is a good justification not to (e.g. the list is sorted alphabetically).
Show 12 quoted lines
> diff --git a/setup.c b/setup.c
> index 5ea5502..15bc305 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -808,3 +808,10 @@ const char *setup_git_directory(void)
> {
> return setup_git_directory_gently(NULL);
> }
> +
> +const char *resolve_gitdir(const char *suspect)
> +{
> + if(is_git_directory(suspect))(style) SP immediately after "if".