mirror of
https://github.com/git/git
synced 2024-10-06 00:29:28 +00:00
Merge branch 'js/scalar-global-options'
Scalar update. * js/scalar-global-options: scalar: accept -C and -c options before the subcommand
This commit is contained in:
commit
ff6f1695a3
|
@ -808,6 +808,25 @@ int cmd_main(int argc, const char **argv)
|
||||||
struct strbuf scalar_usage = STRBUF_INIT;
|
struct strbuf scalar_usage = STRBUF_INIT;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
while (argc > 1 && *argv[1] == '-') {
|
||||||
|
if (!strcmp(argv[1], "-C")) {
|
||||||
|
if (argc < 3)
|
||||||
|
die(_("-C requires a <directory>"));
|
||||||
|
if (chdir(argv[2]) < 0)
|
||||||
|
die_errno(_("could not change to '%s'"),
|
||||||
|
argv[2]);
|
||||||
|
argc -= 2;
|
||||||
|
argv += 2;
|
||||||
|
} else if (!strcmp(argv[1], "-c")) {
|
||||||
|
if (argc < 3)
|
||||||
|
die(_("-c requires a <key>=<value> argument"));
|
||||||
|
git_config_push_parameter(argv[2]);
|
||||||
|
argc -= 2;
|
||||||
|
argv += 2;
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
argv++;
|
argv++;
|
||||||
argc--;
|
argc--;
|
||||||
|
@ -818,7 +837,8 @@ int cmd_main(int argc, const char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf_addstr(&scalar_usage,
|
strbuf_addstr(&scalar_usage,
|
||||||
N_("scalar <command> [<options>]\n\nCommands:\n"));
|
N_("scalar [-C <directory>] [-c <key>=<value>] "
|
||||||
|
"<command> [<options>]\n\nCommands:\n"));
|
||||||
for (i = 0; builtins[i].name; i++)
|
for (i = 0; builtins[i].name; i++)
|
||||||
strbuf_addf(&scalar_usage, "\t%s\n", builtins[i].name);
|
strbuf_addf(&scalar_usage, "\t%s\n", builtins[i].name);
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,16 @@ The `scalar` command implements various subcommands, and different options
|
||||||
depending on the subcommand. With the exception of `clone`, `list` and
|
depending on the subcommand. With the exception of `clone`, `list` and
|
||||||
`reconfigure --all`, all subcommands expect to be run in an enlistment.
|
`reconfigure --all`, all subcommands expect to be run in an enlistment.
|
||||||
|
|
||||||
|
The following options can be specified _before_ the subcommand:
|
||||||
|
|
||||||
|
-C <directory>::
|
||||||
|
Before running the subcommand, change the working directory. This
|
||||||
|
option imitates the same option of linkgit:git[1].
|
||||||
|
|
||||||
|
-c <key>=<value>::
|
||||||
|
For the duration of running the specified subcommand, configure this
|
||||||
|
setting. This option imitates the same option of linkgit:git[1].
|
||||||
|
|
||||||
COMMANDS
|
COMMANDS
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
@ -85,4 +85,12 @@ test_expect_success 'scalar delete with enlistment' '
|
||||||
test_path_is_missing cloned
|
test_path_is_missing cloned
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'scalar supports -c/-C' '
|
||||||
|
test_when_finished "scalar delete sub" &&
|
||||||
|
git init sub &&
|
||||||
|
scalar -C sub -c status.aheadBehind=bogus register &&
|
||||||
|
test -z "$(git -C sub config --local status.aheadBehind)" &&
|
||||||
|
test true = "$(git -C sub config core.preloadIndex)"
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue