Skip to content

Commit 43a8391

Browse files
Unique-Usmangitster
authored andcommitted
builtin/verify-tag: stop using the_repository
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 <[email protected]> Signed-off-by: Usman Akinyemi <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f29f199 commit 43a8391

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

builtin/verify-tag.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*
66
* Based on git-verify-tag.sh
77
*/
8-
#define USE_THE_REPOSITORY_VARIABLE
98
#include "builtin.h"
109
#include "config.h"
1110
#include "gettext.h"
@@ -23,7 +22,7 @@ static const char * const verify_tag_usage[] = {
2322
int cmd_verify_tag(int argc,
2423
const char **argv,
2524
const char *prefix,
26-
struct repository *repo UNUSED)
25+
struct repository *repo)
2726
{
2827
int i = 1, verbose = 0, had_error = 0;
2928
unsigned flags = 0;
@@ -35,7 +34,7 @@ int cmd_verify_tag(int argc,
3534
OPT_END()
3635
};
3736

38-
git_config(git_default_config, NULL);
37+
repo_config(repo, git_default_config, NULL);
3938

4039
argc = parse_options(argc, argv, prefix, verify_tag_options,
4140
verify_tag_usage, PARSE_OPT_KEEP_ARGV0);
@@ -56,7 +55,7 @@ int cmd_verify_tag(int argc,
5655
struct object_id oid;
5756
const char *name = argv[i++];
5857

59-
if (repo_get_oid(the_repository, name, &oid)) {
58+
if (repo_get_oid(repo, name, &oid)) {
6059
had_error = !!error("tag '%s' not found.", name);
6160
continue;
6261
}

t/t7030-verify-tag.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77
. ./test-lib.sh
88
. "$TEST_DIRECTORY/lib-gpg.sh"
99

10+
test_expect_success GPG 'verify-tag does not crash with -h' '
11+
test_expect_code 129 git verify-tag -h >usage &&
12+
test_grep "[Uu]sage: git verify-tag " usage &&
13+
test_expect_code 129 nongit git verify-tag -h >usage &&
14+
test_grep "[Uu]sage: git verify-tag " usage
15+
'
16+
1017
test_expect_success GPG 'create signed tags' '
1118
echo 1 >file && git add file &&
1219
test_tick && git commit -m initial &&

0 commit comments

Comments
 (0)