zsh-workers
 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; 12+ messages in thread
From: eliasghafari @ 2023-03-09 12:33 UTC (permalink / raw)
  To: zsh-workers

Hello,

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] 12+ messages in thread
* Re: [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...)
@ 2023-09-12  8:54 eliasghafari
  2023-09-12  9:34 ` Roman Perepelitsa
  0 siblings, 1 reply; 12+ messages in thread
From: eliasghafari @ 2023-09-12  8:54 UTC (permalink / raw)
  To: zsh-workers

After using <C-x ?> instead of <Tab> (Thanks Bart) and looking at the output I found
that:
alias config='git --git-dir ~/.local/share/dotfiles --work-tree ~'
works perfectly.
And Jun T's solution of:
alias config="git --git-dir=$HOME/.local/share/dotfiles --work-tree $HOME"
Also works I never knew that there was a difference between ' and ".

Thanks for the help.


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

end of thread, other threads:[~2023-09-12 19:33 UTC | newest]

Thread overview: 12+ 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
2023-09-11 15:05       ` Elias Ghafari
2023-09-12  2:26         ` Jun T
2023-09-12  8:54 eliasghafari
2023-09-12  9:34 ` Roman Perepelitsa
2023-09-12 19:25   ` eliasghafari
2023-09-12 19:33     ` Roman Perepelitsa

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

	https://git.vuxu.org/mirror/zsh/

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).