diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-03-10 14:23:23 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-10 14:23:24 -0700 |
| commit | 42afcb954bd4a69deba0a7b9823a9307b4223136 (patch) | |
| tree | 59b6904d13d67ae2e581e01ebf61f0309d888d1c | |
| parent | 08c36099359e6a5c694f9abb97e630a247bc8dfb (diff) | |
| parent | 73cc549559398626f33063f64ece9e558e654c95 (diff) | |
| download | git-42afcb954bd4a69deba0a7b9823a9307b4223136.tar.xz | |
Merge branch 'jh/alias-i18n-fixes'
Further update to the i18n alias support to avoid regressions.
* jh/alias-i18n-fixes:
doc: fix list continuation in alias.adoc
git, help: fix memory leaks in alias listing
alias: treat empty subsection [alias ""] as plain [alias]
doc: fix list continuation in alias subsection example
| -rw-r--r-- | Documentation/config/alias.adoc | 9 | ||||
| -rw-r--r-- | alias.c | 4 | ||||
| -rw-r--r-- | git.c | 2 | ||||
| -rw-r--r-- | help.c | 2 | ||||
| -rwxr-xr-x | t/t0014-alias.sh | 14 |
5 files changed, 25 insertions, 6 deletions
diff --git a/Documentation/config/alias.adoc b/Documentation/config/alias.adoc index 115fdbb1e3..dc6ca0ee08 100644 --- a/Documentation/config/alias.adoc +++ b/Documentation/config/alias.adoc @@ -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`. To avoid -confusion and troubles with script usage, aliases that ++ +`git last` is equivalent to `git cat-file commit HEAD`. ++ +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. @@ -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; @@ -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; } @@ -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; diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh index 34bbdb51c5..68b4903cbf 100755 --- a/t/t0014-alias.sh +++ b/t/t0014-alias.sh @@ -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 |
