Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...)



eliasghafari wrote:
> 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'",

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

> 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

I would suggest you try using ~ instead of $HOME in your alias:

  alias config='git --git-dir=~/.local/share/dotfiles --work-tree=~'

The tilde in ${~opt_args[--git-dir]}} ensures that tildes are expanded.
While using (e) is arguably the right thing to do, it will expand things
like command-substitution and we've always intentionally shied away
from expanding anything that could have side-effects when parsing the
command-line for completion.

The modifiers don't allow you to pick-and-choose expansions so there
isn't a trivial way to expand variable references without expanding more
problematic things.

Oliver




Messages sorted by: Reverse Date, Date, Thread, Author