From: Junio C Hamano <gitster@pobox.com>
To: Tian Yuchen <cat@malon.dev>
Cc: Patrick Steinhardt <ps@pks.im>,
git@vger.kernel.org, karthik.188@gmail.com,
phillip.wood@dunelm.org.uk, jltobler@gmail.com
Subject: Re: [PATCH v1] builtin/mktree: remove USE_THE_REPOSITORY_VARIABLE
Date: Fri, 13 Mar 2026 09:03:29 -0700 [thread overview]
Message-ID: <xmqqpl577m3y.fsf@gitster.g> (raw)
In-Reply-To: <af2c4ae3-c273-40ba-bbca-cbbf687b1b91@malon.dev> (Tian Yuchen's message of "Fri, 13 Mar 2026 00:21:41 +0800")
Tian Yuchen <cat@malon.dev> writes:
>> That is, can `repo` ever be `NULL`? For that
>> you have to look at "git.c" and figure out whether or not the command
>> requires a repository to exist.
> I checked git.c and found that there is:
>
> { "mktree", cmd_mktree, RUN_SETUP }
>
> in commands[]. If my understanding is correct, before cmd_mktree is
> called, setup_git_directory() must have been fully executed. In that
> case, if the current directory isn't a valid repository (NULL), it
> should have already exited at an earlier stage, right?
There is one corner case; upon "git foo -h", your cmd_foo() will get
repo==NULL when the command is run outside a repository. As long as
your cmd_foo() asks parse_options() to react to "-h" (which gives
the help message and then exits) before it uses repo assuming it
cannot be NULL, you are safe.
next prev parent reply other threads:[~2026-03-13 16:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 18:17 [PATCH v1] builtin/mktree: remove USE_THE_REPOSITORY_VARIABLE Tian Yuchen
2026-03-12 6:55 ` Patrick Steinhardt
2026-03-12 16:21 ` Tian Yuchen
2026-03-13 7:02 ` Patrick Steinhardt
2026-03-13 16:03 ` Junio C Hamano [this message]
2026-03-13 17:15 ` Tian Yuchen
2026-03-13 17:54 ` Junio C Hamano
2026-03-13 18:12 ` Tian Yuchen
2026-03-13 20:20 ` Junio C Hamano
2026-03-14 3:17 ` Tian Yuchen
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=xmqqpl577m3y.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=cat@malon.dev \
--cc=git@vger.kernel.org \
--cc=jltobler@gmail.com \
--cc=karthik.188@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
/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.