From: Usman Akinyemi <usmanakinyemi202@gmail.com>
To: git@vger.kernel.org, christian.couder@gmail.com
Cc: gitster@pobox.com, johncai86@gmail.com, me@ttaylorr.com,
phillip.wood123@gmail.com, ps@pks.im, shejialuo@gmail.com,
Christian Couder <chriscool@tuxfamily.org>
Subject: [PATCH 2/9] builtin/verify-tag: stop using `the_repository`
Date: Tue, 18 Mar 2025 17:28:54 +0530 [thread overview]
Message-ID: <20250318115912.2978992-3-usmanakinyemi202@gmail.com> (raw)
In-Reply-To: <20250318115912.2978992-1-usmanakinyemi202@gmail.com>
Remove the_repository global variable in favor of the repository
argument that gets passed in "builtin/verify-tag.c".
When `-h` is passed to the command outside a Git repository, the
`run_builtin()` will call the `cmd_verify_tag()` function with `repo` set
to NULL and then early in the function, `parse_options()` call will give
the options help and exit.
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
builtin/verify-tag.c | 7 +++----
t/t7030-verify-tag.sh | 7 +++++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index f6b97048a5..ed1c40338f 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -5,7 +5,6 @@
*
* Based on git-verify-tag.sh
*/
-#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "gettext.h"
@@ -23,7 +22,7 @@ static const char * const verify_tag_usage[] = {
int cmd_verify_tag(int argc,
const char **argv,
const char *prefix,
- struct repository *repo UNUSED)
+ struct repository *repo)
{
int i = 1, verbose = 0, had_error = 0;
unsigned flags = 0;
@@ -35,7 +34,7 @@ int cmd_verify_tag(int argc,
OPT_END()
};
- git_config(git_default_config, NULL);
+ repo_config(repo, git_default_config, NULL);
argc = parse_options(argc, argv, prefix, verify_tag_options,
verify_tag_usage, PARSE_OPT_KEEP_ARGV0);
@@ -56,7 +55,7 @@ int cmd_verify_tag(int argc,
struct object_id oid;
const char *name = argv[i++];
- if (repo_get_oid(the_repository, name, &oid)) {
+ if (repo_get_oid(repo, name, &oid)) {
had_error = !!error("tag '%s' not found.", name);
continue;
}
diff --git a/t/t7030-verify-tag.sh b/t/t7030-verify-tag.sh
index 6f526c37c2..2c147072c1 100755
--- a/t/t7030-verify-tag.sh
+++ b/t/t7030-verify-tag.sh
@@ -7,6 +7,13 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY/lib-gpg.sh"
+test_expect_success GPG 'verify-tag does not crash with -h' '
+ test_expect_code 129 git verify-tag -h >usage &&
+ test_grep "[Uu]sage: git verify-tag " usage &&
+ test_expect_code 129 nongit git verify-tag -h >usage &&
+ test_grep "[Uu]sage: git verify-tag " usage
+'
+
test_expect_success GPG 'create signed tags' '
echo 1 >file && git add file &&
test_tick && git commit -m initial &&
--
2.48.1
next prev parent reply other threads:[~2025-03-18 11:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 11:58 [PATCH 0/9] remove unnecessary if statement Usman Akinyemi
2025-03-18 11:58 ` [PATCH 1/9] config: teach repo_config to allow `repo` to be NULL Usman Akinyemi
2025-03-20 7:21 ` Patrick Steinhardt
2025-03-21 6:56 ` Usman Akinyemi
2025-03-18 11:58 ` Usman Akinyemi [this message]
2025-03-20 7:21 ` [PATCH 2/9] builtin/verify-tag: stop using `the_repository` Patrick Steinhardt
2025-03-18 11:58 ` [PATCH 3/9] builtin/verify-commit: " Usman Akinyemi
2025-03-18 11:58 ` [PATCH 4/9] builtin/send-pack: " Usman Akinyemi
2025-03-18 11:58 ` [PATCH 5/9] builtin/pack-refs: " Usman Akinyemi
2025-03-18 11:58 ` [PATCH 6/9] builtin/ls-files: " Usman Akinyemi
2025-03-18 11:58 ` [PATCH 7/9] builtin/for-each-ref: " Usman Akinyemi
2025-03-18 11:59 ` [PATCH 8/9] builtin/checkout-index: " Usman Akinyemi
2025-03-18 11:59 ` [PATCH 9/9] builtin/update-server-info: remove unnecessary if statement Usman Akinyemi
2025-03-20 7:21 ` Patrick Steinhardt
2025-03-21 7:00 ` Usman Akinyemi
2025-03-18 20:21 ` [PATCH 0/9] " Junio C Hamano
2025-03-19 3:53 ` Usman Akinyemi
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=20250318115912.2978992-3-usmanakinyemi202@gmail.com \
--to=usmanakinyemi202@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johncai86@gmail.com \
--cc=me@ttaylorr.com \
--cc=phillip.wood123@gmail.com \
--cc=ps@pks.im \
--cc=shejialuo@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).