mirror of
https://github.com/git/git.git
synced 2026-05-25 11:25:06 +02:00
Merge branch 'jh/alias-i18n-fixes'
Further update to the i18n alias support to avoid regressions. * jh/alias-i18n-fixes: alias: restore support for simple dotted aliases
This commit is contained in:
@@ -34,8 +34,20 @@ static int config_alias_cb(const char *var, const char *value,
|
||||
if (subsection && !subsection_len)
|
||||
subsection = NULL;
|
||||
|
||||
if (subsection && strcmp(key, "command"))
|
||||
return 0;
|
||||
if (subsection && strcmp(key, "command")) {
|
||||
/*
|
||||
* We have historically supported the "alias.name" form when
|
||||
* "name" happens to contain dots (e.g., alias.foo.bar to allow
|
||||
* "git foo.bar". But our parsing above would split that into
|
||||
* subsection "foo".
|
||||
*
|
||||
* If we do not understand the final key in a subsection-style
|
||||
* variable, fall back to treating it as a two-level alias.
|
||||
*/
|
||||
key = var + strlen("alias.");
|
||||
subsection = NULL;
|
||||
subsection_len = 0;
|
||||
}
|
||||
|
||||
if (data->alias) {
|
||||
int match;
|
||||
|
||||
@@ -592,14 +592,21 @@ static int git_unknown_cmd_config(const char *var, const char *value,
|
||||
/* Also use aliases for command lookup */
|
||||
if (!parse_config_key(var, "alias", &subsection, &subsection_len,
|
||||
&key)) {
|
||||
size_t key_len = strlen(key);
|
||||
|
||||
if (subsection) {
|
||||
/* [alias "name"] command = value */
|
||||
if (!strcmp(key, "command"))
|
||||
add_cmdname(&cfg->aliases, subsection,
|
||||
subsection_len);
|
||||
else {
|
||||
key = var + strlen("alias.");
|
||||
key_len = strlen(key);
|
||||
add_cmdname(&cfg->aliases, key, key_len);
|
||||
}
|
||||
} else {
|
||||
/* alias.name = value */
|
||||
add_cmdname(&cfg->aliases, key, strlen(key));
|
||||
add_cmdname(&cfg->aliases, key, key_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +128,12 @@ test_expect_success 'subsection syntax works' '
|
||||
test_grep "ran-subsection" output
|
||||
'
|
||||
|
||||
test_expect_success 'simple dotted alias syntax still works' '
|
||||
test_config alias.simple.dotted "!echo ran-simple-dotted" &&
|
||||
git simple.dotted >output &&
|
||||
test_grep "ran-simple-dotted" output
|
||||
'
|
||||
|
||||
test_expect_success 'subsection syntax only accepts command key' '
|
||||
test_config alias.invalid.notcommand value &&
|
||||
test_must_fail git invalid 2>error &&
|
||||
@@ -183,6 +189,12 @@ test_expect_success 'subsection aliases listed in help -a' '
|
||||
test_grep "förgrena" output
|
||||
'
|
||||
|
||||
test_expect_success 'simple dotted aliases listed in help -a' '
|
||||
test_config alias.simple.listed "!echo test" &&
|
||||
git help -a >output &&
|
||||
test_grep "simple.listed" output
|
||||
'
|
||||
|
||||
test_expect_success 'empty subsection treated as no subsection' '
|
||||
test_config "alias..something" "!echo foobar" &&
|
||||
git something >actual &&
|
||||
|
||||
Reference in New Issue
Block a user