summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordana <dana@dana.is>2025-11-17 21:06:07 -0600
committerdana <dana@dana.is>2025-11-22 13:52:09 -0600
commitf9f83d20f802de905cc9995a49640d5c497167e6 (patch)
tree55f7fb71fb0f7ceb357242bef69b8e50bd8e579f
parent54091: _git: add support for more pretty format specifiers (diff)
downloadzsh-f9f83d20f802de905cc9995a49640d5c497167e6.tar
zsh-f9f83d20f802de905cc9995a49640d5c497167e6.tar.gz
zsh-f9f83d20f802de905cc9995a49640d5c497167e6.tar.bz2
zsh-f9f83d20f802de905cc9995a49640d5c497167e6.tar.lz
zsh-f9f83d20f802de905cc9995a49640d5c497167e6.tar.xz
zsh-f9f83d20f802de905cc9995a49640d5c497167e6.tar.zst
zsh-f9f83d20f802de905cc9995a49640d5c497167e6.zip
54092 (tweaked): _git: improve format completion
- complete user-defined formats (pretty.<name> in config) - complete tformat: syntax - auto-remove extra : when completing (t|)format: - add new place-holders + added comment per off-list suggestion
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_git28
2 files changed, 30 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index ea2aa53fb..88bc4a5e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2025-11-22 dana <dana@dana.is>
+
+ * 54092 (tweaked): Completion/Unix/Command/_git: improve format
+ completion
+
2025-11-17 Oliver Kiddle <opk@zsh.org>
* Arseny Maslennikov: 54091: Completion/Unix/Command/_git:
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 89f78ecb3..8d2239cba 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -8228,7 +8228,10 @@ __git_setup_diff_stage_options () {
__git_format_placeholders() {
local sep
local -a disp names placeholders expl
- _describe -t formats format '( oneline:"<hash> <title>"
+ local -a builtin_fmts user_fmts custom_fmts
+
+ builtin_fmts=(
+ oneline:"<hash> <title>"
short:"commit hash plus author and title headers"
medium:"like short plus author date header and full message"
full:"like medium with committer header instead of date"
@@ -8236,8 +8239,26 @@ __git_format_placeholders() {
reference:"<abbrev hash> (<title>, <short author date>)"
email:"email patch format"
mboxrd:"like email with From lines in message quoted with >"
- raw:"entire commit object" )' -- '( format:"specify own format" )' -S ':' && return
- compset -P 'format:'
+ raw:"entire commit object"
+ )
+
+ __git_config_get_regexp '^pretty\.' user_fmts
+ user_fmts=( ${${${user_fmts//:/\\:}#pretty.}/$'\n'/:} )
+
+ custom_fmts=(
+ format:"specify own format (separator semantics)"
+ tformat:"specify own format (terminator semantics)"
+ )
+
+ _alternative \
+ 'formats:: _describe -t formats "built-in format" builtin_fmts' \
+ 'user-formats:: _describe -t user-formats "user format" user_fmts' \
+ 'custom-formats:: _describe -t custom-formats "custom format" custom_fmts -qS:' \
+ && return
+
+ # @todo: still unsupported: more complicated place-holders like %C() and
+ # %(describe:), and the %-x %+x syntax
+ compset -P '(t|)format:'
compset -P '(%[^acgCG]|%?[^%]|[^%])#'
if compset -P '%C'; then
_wanted colors expl color compadd reset red green blue
@@ -8251,6 +8272,7 @@ __git_format_placeholders() {
'GK:signing key'
'GF:fingerprint of signing key'
'GP:fingerprint of primary key whose subkey was used to sign'
+ 'GT:trust level of signing key'
)
disp=( -l )
elif [[ -prefix %g ]]; then