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

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".
Previous: Fredrik GustafssonNext: Fredrik Gustafsson
Message 3 of 8 in “submodule: move gitdir into superproject”
  1. 0/2 submodule: move gitdir into superprojectFredrik Gustafsson, Aug 8, 2011
  2. 1/2 rev-parse: add option --is-well-formed-git-dir [path]Fredrik Gustafsson, Aug 8, 2011
  3. Junio C HamanoAug 11, 2011
  4. 2/2 Move git-dir for submodulesFredrik Gustafsson, Aug 8, 2011
  5. Heiko VoigtAug 8, 2011
  6. Junio C HamanoAug 8, 2011
  7. Heiko VoigtAug 9, 2011
  8. Junio C HamanoAug 11, 2011

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.