From: Junio C Hamano <gitster@pobox.com>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/2] reflog: drop usage of global variables
Date: Fri, 07 Mar 2025 13:19:28 -0800 [thread overview]
Message-ID: <xmqqo6ycczdr.fsf@gitster.g> (raw)
In-Reply-To: <20250307-493-add-command-to-purge-reflog-entries-v1-1-84ab8529cf9e@gmail.com> (Karthik Nayak's message of "Fri, 07 Mar 2025 12:17:25 +0100")
Karthik Nayak <karthik.188@gmail.com> writes:
> The 'builtin/reflog.c' file uses the 'the_repository' global variable
> directly and also via 'git_config()'. Since this is a builtin command
> which has access to the 'struct repository', drop usage of the global
> variable and use the available repository struct.
>
> With this, remove the 'USE_THE_REPOSITORY_VARIABLE' macro from the file.
I suspect that this is not quite right.
$ cd w/git.git/; make
$ ./git-reflog list -h
usage: git reflog list
$ cd .. # not a repository
$ git.git/git-reflog list -h
fatal: not a git repository (or any of the parent directories): .git
$ git.git/git-reflog -h
usage: git reflog [show] ...
but I also suspect that it is mostly due to the original program
structure that uses OPT_SUBCOMMAND() that the subcommands fail to
respond to "-h" unlike the top-level command, so this may not be a
regression. I do think however that this change is making it harder
to fix.
In any case, when you are adding a new feature, I would strongly
prefer you did *not* take it hostage to unrelated internal clean-up
with a dubious value. For the library-ish parts of the system
(e.g. reflog.c at the top-level), not depending on the_repository is
absolutely the good thing to do, but the top level cmd_foo() are not
meant to be called as helper functions repeatedly with arbirary
repository instance, and a churn like this one, only to mollify the
USE_THE_REPOSITORY_VARIABLE macro, does not deserve to take a more
interesting (in the sense that it improves the life of end users)
change hostage by pretending to be its prerequisite clean-up.
Thanks.
next prev parent reply other threads:[~2025-03-07 21:19 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 11:17 [PATCH 0/2] EDITME: cover title for 493-add-command-to-purge-reflog-entries Karthik Nayak
2025-03-07 11:17 ` [PATCH 1/2] reflog: drop usage of global variables Karthik Nayak
2025-03-07 21:19 ` Junio C Hamano [this message]
2025-03-10 11:41 ` Karthik Nayak
2025-03-10 15:24 ` Junio C Hamano
2025-03-13 13:30 ` Karthik Nayak
2025-03-07 11:17 ` [PATCH 2/2] reflog: implement subcommand to drop reflogs Karthik Nayak
2025-03-07 11:50 ` Patrick Steinhardt
2025-03-07 12:53 ` Karthik Nayak
2025-03-07 12:59 ` Patrick Steinhardt
2025-03-07 13:28 ` Karthik Nayak
2025-03-07 13:28 ` Karthik Nayak
2025-03-07 21:28 ` Junio C Hamano
2025-03-10 11:28 ` Karthik Nayak
2025-03-10 7:39 ` [PATCH 0/2] EDITME: cover title for 493-add-command-to-purge-reflog-entries Kristoffer Haugsbakk
2025-03-10 12:34 ` Karthik Nayak
2025-03-10 15:28 ` Junio C Hamano
2025-03-10 12:36 ` [PATCH v2] reflog: implement subcommand to drop reflogs Karthik Nayak
2025-03-12 7:15 ` Patrick Steinhardt
2025-03-13 14:24 ` Karthik Nayak
2025-03-13 14:45 ` Patrick Steinhardt
2025-03-14 8:40 ` [PATCH v3 0/2] " Karthik Nayak
2025-03-14 8:40 ` [PATCH v3 1/2] reflog: improve error for when reflog is not found Karthik Nayak
2025-03-14 8:40 ` [PATCH v3 2/2] reflog: implement subcommand to drop reflogs Karthik Nayak
2025-03-18 14:01 ` Christian Couder
2025-03-18 17:44 ` Junio C Hamano
2025-03-19 8:17 ` Christian Couder
2025-03-19 9:06 ` Karthik Nayak
2025-03-18 15:56 ` Toon Claes
2025-03-19 9:16 ` Karthik Nayak
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=xmqqo6ycczdr.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=karthik.188@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).