Skip to content

Commit cd37c45

Browse files
committed
Merge branch 'ab/test-env-helper'
Remove "git env--helper" and demote it to a test-tool subcommand. * ab/test-env-helper: env-helper: move this built-in to "test-tool env-helper"
2 parents 577bff3 + 4a1baac commit cd37c45

File tree

9 files changed

+50
-50
lines changed

9 files changed

+50
-50
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
/git-difftool
6060
/git-difftool--helper
6161
/git-describe
62-
/git-env--helper
6362
/git-fast-export
6463
/git-fast-import
6564
/git-fetch

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ TEST_BUILTINS_OBJS += test-dump-cache-tree.o
798798
TEST_BUILTINS_OBJS += test-dump-fsmonitor.o
799799
TEST_BUILTINS_OBJS += test-dump-split-index.o
800800
TEST_BUILTINS_OBJS += test-dump-untracked-cache.o
801+
TEST_BUILTINS_OBJS += test-env-helper.o
801802
TEST_BUILTINS_OBJS += test-example-decorate.o
802803
TEST_BUILTINS_OBJS += test-fast-rebase.o
803804
TEST_BUILTINS_OBJS += test-fsmonitor-client.o
@@ -1231,7 +1232,6 @@ BUILTIN_OBJS += builtin/diff-index.o
12311232
BUILTIN_OBJS += builtin/diff-tree.o
12321233
BUILTIN_OBJS += builtin/diff.o
12331234
BUILTIN_OBJS += builtin/difftool.o
1234-
BUILTIN_OBJS += builtin/env--helper.o
12351235
BUILTIN_OBJS += builtin/fast-export.o
12361236
BUILTIN_OBJS += builtin/fast-import.o
12371237
BUILTIN_OBJS += builtin/fetch-pack.o

git.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ static struct cmd_struct commands[] = {
507507
{ "diff-index", cmd_diff_index, RUN_SETUP | NO_PARSEOPT },
508508
{ "diff-tree", cmd_diff_tree, RUN_SETUP | NO_PARSEOPT },
509509
{ "difftool", cmd_difftool, RUN_SETUP_GENTLY },
510-
{ "env--helper", cmd_env__helper },
511510
{ "fast-export", cmd_fast_export, RUN_SETUP },
512511
{ "fast-import", cmd_fast_import, RUN_SETUP | NO_PARSEOPT },
513512
{ "fetch", cmd_fetch, RUN_SETUP },

builtin/env--helper.c renamed to t/helper/test-env-helper.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#include "builtin.h"
1+
#include "test-tool.h"
22
#include "config.h"
33
#include "parse-options.h"
44

55
static char const * const env__helper_usage[] = {
6-
N_("git env--helper --type=[bool|ulong] <options> <env-var>"),
6+
"test-tool env-helper --type=[bool|ulong] <options> <env-var>",
77
NULL
88
};
99

@@ -24,12 +24,12 @@ static int option_parse_type(const struct option *opt, const char *arg,
2424
else if (!strcmp(arg, "ulong"))
2525
*cmdmode = ENV_HELPER_TYPE_ULONG;
2626
else
27-
die(_("unrecognized --type argument, %s"), arg);
27+
die("unrecognized --type argument, %s", arg);
2828

2929
return 0;
3030
}
3131

32-
int cmd_env__helper(int argc, const char **argv, const char *prefix)
32+
int cmd__env_helper(int argc, const char **argv)
3333
{
3434
int exit_code = 0;
3535
const char *env_variable = NULL;
@@ -39,17 +39,17 @@ int cmd_env__helper(int argc, const char **argv, const char *prefix)
3939
unsigned long ret_ulong, default_ulong;
4040
enum cmdmode cmdmode = 0;
4141
struct option opts[] = {
42-
OPT_CALLBACK_F(0, "type", &cmdmode, N_("type"),
43-
N_("value is given this type"), PARSE_OPT_NONEG,
42+
OPT_CALLBACK_F(0, "type", &cmdmode, "type",
43+
"value is given this type", PARSE_OPT_NONEG,
4444
option_parse_type),
45-
OPT_STRING(0, "default", &env_default, N_("value"),
46-
N_("default for git_env_*(...) to fall back on")),
45+
OPT_STRING(0, "default", &env_default, "value",
46+
"default for git_env_*(...) to fall back on"),
4747
OPT_BOOL(0, "exit-code", &exit_code,
48-
N_("be quiet only use git_env_*() value as exit code")),
48+
"be quiet only use git_env_*() value as exit code"),
4949
OPT_END(),
5050
};
5151

52-
argc = parse_options(argc, argv, prefix, opts, env__helper_usage,
52+
argc = parse_options(argc, argv, NULL, opts, env__helper_usage,
5353
PARSE_OPT_KEEP_UNKNOWN_OPT);
5454
if (env_default && !*env_default)
5555
usage_with_options(env__helper_usage, opts);
@@ -64,7 +64,7 @@ int cmd_env__helper(int argc, const char **argv, const char *prefix)
6464
if (env_default) {
6565
default_int = git_parse_maybe_bool(env_default);
6666
if (default_int == -1) {
67-
error(_("option `--default' expects a boolean value with `--type=bool`, not `%s`"),
67+
error("option `--default' expects a boolean value with `--type=bool`, not `%s`",
6868
env_default);
6969
usage_with_options(env__helper_usage, opts);
7070
}
@@ -79,7 +79,7 @@ int cmd_env__helper(int argc, const char **argv, const char *prefix)
7979
case ENV_HELPER_TYPE_ULONG:
8080
if (env_default) {
8181
if (!git_parse_ulong(env_default, &default_ulong)) {
82-
error(_("option `--default' expects an unsigned long value with `--type=ulong`, not `%s`"),
82+
error("option `--default' expects an unsigned long value with `--type=ulong`, not `%s`",
8383
env_default);
8484
usage_with_options(env__helper_usage, opts);
8585
}

t/helper/test-tool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ static struct test_cmd cmds[] = {
2828
{ "dump-fsmonitor", cmd__dump_fsmonitor },
2929
{ "dump-split-index", cmd__dump_split_index },
3030
{ "dump-untracked-cache", cmd__dump_untracked_cache },
31+
{ "env-helper", cmd__env_helper },
3132
{ "example-decorate", cmd__example_decorate },
3233
{ "fast-rebase", cmd__fast_rebase },
3334
{ "fsmonitor-client", cmd__fsmonitor_client },

t/helper/test-tool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ int cmd__dump_fsmonitor(int argc, const char **argv);
2222
int cmd__dump_split_index(int argc, const char **argv);
2323
int cmd__dump_untracked_cache(int argc, const char **argv);
2424
int cmd__dump_reftable(int argc, const char **argv);
25+
int cmd__env_helper(int argc, const char **argv);
2526
int cmd__example_decorate(int argc, const char **argv);
2627
int cmd__fast_rebase(int argc, const char **argv);
2728
int cmd__fsmonitor_client(int argc, const char **argv);

t/t0017-env-helper.sh

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
11
#!/bin/sh
22

3-
test_description='test env--helper'
3+
test_description='test test-tool env-helper'
44

55
TEST_PASSES_SANITIZE_LEAK=true
66
. ./test-lib.sh
77

88

9-
test_expect_success 'env--helper usage' '
10-
test_must_fail git env--helper &&
11-
test_must_fail git env--helper --type=bool &&
12-
test_must_fail git env--helper --type=ulong &&
13-
test_must_fail git env--helper --type=bool &&
14-
test_must_fail git env--helper --type=bool --default &&
15-
test_must_fail git env--helper --type=bool --default= &&
16-
test_must_fail git env--helper --defaultxyz
9+
test_expect_success 'test-tool env-helper usage' '
10+
test_must_fail test-tool env-helper &&
11+
test_must_fail test-tool env-helper --type=bool &&
12+
test_must_fail test-tool env-helper --type=ulong &&
13+
test_must_fail test-tool env-helper --type=bool &&
14+
test_must_fail test-tool env-helper --type=bool --default &&
15+
test_must_fail test-tool env-helper --type=bool --default= &&
16+
test_must_fail test-tool env-helper --defaultxyz
1717
'
1818

19-
test_expect_success 'env--helper bad default values' '
20-
test_must_fail git env--helper --type=bool --default=1xyz MISSING &&
21-
test_must_fail git env--helper --type=ulong --default=1xyz MISSING
19+
test_expect_success 'test-tool env-helper bad default values' '
20+
test_must_fail test-tool env-helper --type=bool --default=1xyz MISSING &&
21+
test_must_fail test-tool env-helper --type=ulong --default=1xyz MISSING
2222
'
2323

24-
test_expect_success 'env--helper --type=bool' '
24+
test_expect_success 'test-tool env-helper --type=bool' '
2525
# Test various --default bool values
2626
echo true >expected &&
27-
git env--helper --type=bool --default=1 MISSING >actual &&
27+
test-tool env-helper --type=bool --default=1 MISSING >actual &&
2828
test_cmp expected actual &&
29-
git env--helper --type=bool --default=yes MISSING >actual &&
29+
test-tool env-helper --type=bool --default=yes MISSING >actual &&
3030
test_cmp expected actual &&
31-
git env--helper --type=bool --default=true MISSING >actual &&
31+
test-tool env-helper --type=bool --default=true MISSING >actual &&
3232
test_cmp expected actual &&
3333
echo false >expected &&
34-
test_must_fail git env--helper --type=bool --default=0 MISSING >actual &&
34+
test_must_fail test-tool env-helper --type=bool --default=0 MISSING >actual &&
3535
test_cmp expected actual &&
36-
test_must_fail git env--helper --type=bool --default=no MISSING >actual &&
36+
test_must_fail test-tool env-helper --type=bool --default=no MISSING >actual &&
3737
test_cmp expected actual &&
38-
test_must_fail git env--helper --type=bool --default=false MISSING >actual &&
38+
test_must_fail test-tool env-helper --type=bool --default=false MISSING >actual &&
3939
test_cmp expected actual &&
4040
4141
# No output with --exit-code
42-
git env--helper --type=bool --default=true --exit-code MISSING >actual.out 2>actual.err &&
42+
test-tool env-helper --type=bool --default=true --exit-code MISSING >actual.out 2>actual.err &&
4343
test_must_be_empty actual.out &&
4444
test_must_be_empty actual.err &&
45-
test_must_fail git env--helper --type=bool --default=false --exit-code MISSING >actual.out 2>actual.err &&
45+
test_must_fail test-tool env-helper --type=bool --default=false --exit-code MISSING >actual.out 2>actual.err &&
4646
test_must_be_empty actual.out &&
4747
test_must_be_empty actual.err &&
4848
4949
# Existing variable
50-
EXISTS=true git env--helper --type=bool --default=false --exit-code EXISTS >actual.out 2>actual.err &&
50+
EXISTS=true test-tool env-helper --type=bool --default=false --exit-code EXISTS >actual.out 2>actual.err &&
5151
test_must_be_empty actual.out &&
5252
test_must_be_empty actual.err &&
5353
test_must_fail \
5454
env EXISTS=false \
55-
git env--helper --type=bool --default=true --exit-code EXISTS >actual.out 2>actual.err &&
55+
test-tool env-helper --type=bool --default=true --exit-code EXISTS >actual.out 2>actual.err &&
5656
test_must_be_empty actual.out &&
5757
test_must_be_empty actual.err
5858
'
5959

60-
test_expect_success 'env--helper --type=ulong' '
60+
test_expect_success 'test-tool env-helper --type=ulong' '
6161
echo 1234567890 >expected &&
62-
git env--helper --type=ulong --default=1234567890 MISSING >actual.out 2>actual.err &&
62+
test-tool env-helper --type=ulong --default=1234567890 MISSING >actual.out 2>actual.err &&
6363
test_cmp expected actual.out &&
6464
test_must_be_empty actual.err &&
6565
6666
echo 0 >expected &&
67-
test_must_fail git env--helper --type=ulong --default=0 MISSING >actual &&
67+
test_must_fail test-tool env-helper --type=ulong --default=0 MISSING >actual &&
6868
test_cmp expected actual &&
6969
70-
git env--helper --type=ulong --default=1234567890 --exit-code MISSING >actual.out 2>actual.err &&
70+
test-tool env-helper --type=ulong --default=1234567890 --exit-code MISSING >actual.out 2>actual.err &&
7171
test_must_be_empty actual.out &&
7272
test_must_be_empty actual.err &&
7373
74-
EXISTS=1234567890 git env--helper --type=ulong --default=0 EXISTS --exit-code >actual.out 2>actual.err &&
74+
EXISTS=1234567890 test-tool env-helper --type=ulong --default=0 EXISTS --exit-code >actual.out 2>actual.err &&
7575
test_must_be_empty actual.out &&
7676
test_must_be_empty actual.err &&
7777
7878
echo 1234567890 >expected &&
79-
EXISTS=1234567890 git env--helper --type=ulong --default=0 EXISTS >actual.out 2>actual.err &&
79+
EXISTS=1234567890 test-tool env-helper --type=ulong --default=0 EXISTS >actual.out 2>actual.err &&
8080
test_cmp expected actual.out &&
8181
test_must_be_empty actual.err
8282
'
8383

84-
test_expect_success 'env--helper reads config thanks to trace2' '
84+
test_expect_success 'test-tool env-helper reads config thanks to trace2' '
8585
mkdir home &&
8686
git config -f home/.gitconfig include.path cycle &&
8787
git config -f home/cycle include.path .gitconfig &&
@@ -93,7 +93,7 @@ test_expect_success 'env--helper reads config thanks to trace2' '
9393
9494
test_must_fail \
9595
env HOME="$(pwd)/home" GIT_TEST_ENV_HELPER=true \
96-
git -C cycle env--helper --type=bool --default=0 --exit-code GIT_TEST_ENV_HELPER 2>err &&
96+
test-tool -C cycle env-helper --type=bool --default=0 --exit-code GIT_TEST_ENV_HELPER 2>err &&
9797
grep "exceeded maximum include depth" err
9898
'
9999

t/test-lib-functions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ test_bool_env () {
14221422
BUG "test_bool_env requires two parameters (variable name and default value)"
14231423
fi
14241424

1425-
git env--helper --type=bool --default="$2" --exit-code "$1"
1425+
test-tool env-helper --type=bool --default="$2" --exit-code "$1"
14261426
ret=$?
14271427
case $ret in
14281428
0|1) # unset or valid bool value

t/test-lib.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,8 +1542,8 @@ then
15421542
# Normalize with test_bool_env
15431543
passes_sanitize_leak=
15441544

1545-
# We need to see TEST_PASSES_SANITIZE_LEAK in "git
1546-
# env--helper" (via test_bool_env)
1545+
# We need to see TEST_PASSES_SANITIZE_LEAK in "test-tool
1546+
# env-helper" (via test_bool_env)
15471547
export TEST_PASSES_SANITIZE_LEAK
15481548
if test_bool_env TEST_PASSES_SANITIZE_LEAK false
15491549
then
@@ -1682,7 +1682,7 @@ yes () {
16821682
# The GIT_TEST_FAIL_PREREQS code hooks into test_set_prereq(), and
16831683
# thus needs to be set up really early, and set an internal variable
16841684
# for convenience so the hot test_set_prereq() codepath doesn't need
1685-
# to call "git env--helper" (via test_bool_env). Only do that work
1685+
# to call "test-tool env-helper" (via test_bool_env). Only do that work
16861686
# if needed by seeing if GIT_TEST_FAIL_PREREQS is set at all.
16871687
GIT_TEST_FAIL_PREREQS_INTERNAL=
16881688
if test -n "$GIT_TEST_FAIL_PREREQS"

0 commit comments

Comments
 (0)