All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Jayesh Daga via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Derrick Stolee <stolee@gmail.com>,
	 Jayesh Daga <jayeshdaga99@gmail.com>
Subject: Re: [PATCH] repo: add paths.toplevel to repo info
Date: Thu, 02 Apr 2026 10:38:47 -0700	[thread overview]
Message-ID: <xmqqpl4hqn2w.fsf@gitster.g> (raw)
In-Reply-To: <pull.2264.git.git.1775150062407.gitgitgadget@gmail.com> (Jayesh Daga via GitGitGadget's message of "Thu, 02 Apr 2026 17:14:22 +0000")

"Jayesh Daga via GitGitGadget" <gitgitgadget@gmail.com> writes:

> +static int get_paths_toplevel(struct repository *repo, struct strbuf *buf)
> +{
> +    const char *wt = repo_get_work_tree(repo);
> +
> +    if (!wt)
> +	return -1; /* match existing error style */
> +
> +    strbuf_addstr(buf, wt);
> +    return 0;
> +}

Funny indentation.  In our C codebase, one level of indent is one
horizontal tab "\t".

> @@ -87,6 +98,7 @@ static const struct repo_info_field repo_info_field[] = {
>  	{ "layout.bare", get_layout_bare },
>  	{ "layout.shallow", get_layout_shallow },
>  	{ "object.format", get_object_format },
> +	{ "paths.toplevel", get_paths_toplevel },
>  	{ "references.format", get_references_format },

Instead of adding yet another one as people think of it, can we
first take an inventory of what is available from the kitchen-sink
options of "git rev-parse" and make a list, to be compared with what
is available in repo_info_field[]?  Add that correspondence table in
a comment before the definition of this array, and it is perfectly
OK if the right hand side on many rows say "missing", like

    /*
     * rev-parse --<opt>	repo info <field>
     *
     * is-bare-repository	layout.bare
     * is-shallow-repository    layout.shallow
     * show-cdup		<missing>
     * show-prefix              <missing>
     * show-object-format       object.format
     * show-ref-format          references.format
     * ... more ...
     */

There can be two classes of <missing>, ones that we want to have but
haven't been implemented eyt, and others that we do not think we
need.

Also, we may not want to limit the existing sources of information
to "rev-parse", in which case lines of such a correspondence table
may need to be grouped by where each piece of information is found
elsewhere.

>  };
>  
> diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
> index 39bb77dda0..470e06e8c2 100755
> --- a/t/t1900-repo-info.sh
> +++ b/t/t1900-repo-info.sh
> @@ -155,4 +155,20 @@ test_expect_success 'git repo info -h shows only repo info usage' '
>  	test_grep ! "git repo structure" actual
>  '
>  
> +test_expect_success 'repo info paths.toplevel' '
> +    git repo info paths.toplevel >actual &&
> +    echo "paths.toplevel=$(git rev-parse --show-toplevel)" >expected &&
> +    test_cmp expected actual
> +'
> +
> +test_expect_success 'repo info paths.toplevel (bare repo)' '
> +    git init --bare bare.git &&
> +    (
> +	cd bare.git &&
> +	git repo info paths.toplevel >actual &&
> +	echo "paths.toplevel=" >expected &&
> +	test_cmp expected actual
> +    )
> +'
> +
>  test_done
>
> base-commit: 256554692df0685b45e60778b08802b720880c50

  reply	other threads:[~2026-04-02 17:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 17:14 [PATCH] repo: add paths.toplevel to repo info Jayesh Daga via GitGitGadget
2026-04-02 17:38 ` Junio C Hamano [this message]
2026-04-08 17:08 ` [PATCH v2] " Jayesh Daga via GitGitGadget
2026-04-09  6:01   ` [PATCH v3] " Jayesh Daga via GitGitGadget
2026-04-09 13:13     ` Karthik Nayak
2026-04-09 14:48       ` Junio C Hamano
2026-04-09 16:01         ` Karthik Nayak
2026-04-09 14:42     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqpl4hqn2w.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=jayeshdaga99@gmail.com \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.