mirror of
https://github.com/git/git.git
synced 2026-03-05 14:59:04 +01:00
Merge branch 'jh/alias-i18n-fixes' (early part) into jch
* 'jh/alias-i18n-fixes' (early part): git, help: fix memory leaks in alias listing alias: treat empty subsection [alias ""] as plain [alias] doc: fix list continuation in alias subsection example
This commit is contained in:
@@ -30,13 +30,14 @@ Examples:
|
||||
----
|
||||
+
|
||||
With a Git alias defined, e.g.,
|
||||
|
||||
+
|
||||
$ git config --global alias.last "cat-file commit HEAD"
|
||||
# Which is equivalent to
|
||||
$ git config --global alias.last.command "cat-file commit HEAD"
|
||||
+
|
||||
`git last` is equivalent to `git cat-file commit HEAD`.
|
||||
|
||||
`git last` is equivalent to `git cat-file commit HEAD`. To avoid
|
||||
confusion and troubles with script usage, aliases that
|
||||
To avoid confusion and troubles with script usage, aliases that
|
||||
hide existing Git commands are ignored except for deprecated
|
||||
commands. Arguments are split by
|
||||
spaces, the usual shell quoting and escaping are supported.
|
||||
|
||||
4
alias.c
4
alias.c
@@ -30,6 +30,10 @@ static int config_alias_cb(const char *var, const char *value,
|
||||
* - [alias "name"]
|
||||
* command = value (with subsection, case-sensitive)
|
||||
*/
|
||||
/* Treat [alias ""] (empty subsection) the same as plain [alias]. */
|
||||
if (subsection && !subsection_len)
|
||||
subsection = NULL;
|
||||
|
||||
if (subsection && strcmp(key, "command"))
|
||||
return 0;
|
||||
|
||||
|
||||
2
git.c
2
git.c
@@ -119,7 +119,7 @@ static int list_cmds(const char *spec)
|
||||
}
|
||||
for (size_t i = 0; i < list.nr; i++)
|
||||
puts(list.items[i].string);
|
||||
string_list_clear(&list, 0);
|
||||
string_list_clear(&list, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
2
help.c
2
help.c
@@ -422,7 +422,7 @@ void list_cmds_by_config(struct string_list *list)
|
||||
if (repo_config_get_string_tmp(the_repository, "completion.commands", &cmd_list))
|
||||
return;
|
||||
|
||||
string_list_sort_u(list, 0);
|
||||
string_list_sort_u(list, 1);
|
||||
|
||||
while (*cmd_list) {
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
|
||||
@@ -183,4 +183,18 @@ test_expect_success 'subsection aliases listed in help -a' '
|
||||
test_grep "förgrena" output
|
||||
'
|
||||
|
||||
test_expect_success 'empty subsection treated as no subsection' '
|
||||
test_config "alias..something" "!echo foobar" &&
|
||||
git something >actual &&
|
||||
echo foobar >expect &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'alias with leading dot via subsection syntax' '
|
||||
test_config alias.".something".command "!echo foobar" &&
|
||||
git .something >actual &&
|
||||
echo foobar >expect &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
||||
Reference in New Issue
Block a user