help / color / mirror / code / Atom feed
From: eliasghafari <eliasghafari@disroot.org>
To: zsh-workers@zsh.org
Subject: [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...)
Date: Thu, 9 Mar 2023 14:33:03 +0200	[thread overview]
Message-ID: <20230309123303.77hztdd63lvxafg4@eliaspc> (raw)


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.

             reply	other threads:[~2023-03-09 12:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09 12:33 eliasghafari [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230309123303.77hztdd63lvxafg4@eliaspc \
    --to=eliasghafari@disroot.org \
    --cc=zsh-workers@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).