help / color / mirror / code / Atom feed
* [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...)
@ 2023-03-09 12:33 eliasghafari
  2023-03-09 17:12 ` Bart Schaefer
  2023-03-09 19:27 ` Oliver Kiddle
  0 siblings, 2 replies; 6+ messages in thread
From: eliasghafari @ 2023-03-09 12:33 UTC (permalink / raw)
  To: zsh-workers


I'm using a git bare repo to manage my files with this alias: "alias config='git --git-dir=$HOME/.local/share/dotfiles --work-tree=$HOME'",
completion for the commands works perfectly, e.g:
config ad<tab>
config add

config rm --ca<tab>
config rm --cached

But when it comes to filenames the autocompletion e.g:
in a normal git repo:
git rm --cached <tab> will show all the files that could be removed from
the index. And
git add <tab> will show all the files that were modified or created.

While using git bare repo:
config rm --cached <tab> doesn't show anything.
config add <tab> also shows nothing

So after investigating a bit, I found that the problem lied in the
expansion of the address of the git-dir and I found that by modifying
this line:
(( $+opt_args[--git-dir] )) && local -x GIT_DIR=${(Q)${~opt_args[--git-dir]}} && printf("\n${(Q)${~opt_args[--git-dir]}}\n")
which shows that the address passed to GIT_DIR is "$HOME/.local/share/dotfiles" without the "$HOME" being expanded to "/home/user".

I fixed this by replacing the Q modifier with e, but please note that I
have no idea how the zsh completion system works and I fixed this by
simply trying every modifier and seeing which one works.

After making that replacement,
config rm --cached <tab> shows what can be removed from the index, and
config add <tab> works too.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-10 10:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 12:33 [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...) eliasghafari
2023-03-09 17:12 ` Bart Schaefer
2023-03-09 19:27 ` Oliver Kiddle
2023-03-09 23:54   ` The (e) parameter flag and side-effects Bart Schaefer
2023-03-10 10:07   ` [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...) Elias Ghafari
2023-03-10 10:12     ` Roman Perepelitsa

Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).