From: Oliver Kiddle <opk@zsh.org>
To: eliasghafari <eliasghafari@disroot.org>
Cc: zsh-workers@zsh.org
Subject: Re: [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...)
Date: Thu, 09 Mar 2023 20:27:48 +0100 [thread overview]
Message-ID: <22530-1678390068.958410@dJKq.2wyk.2KSv> (raw)
In-Reply-To: <20230309123303.77hztdd63lvxafg4@eliaspc>
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
next prev parent reply other threads:[~2023-03-09 19:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 12:33 eliasghafari
2023-03-09 17:12 ` Bart Schaefer
2023-03-09 19:27 ` Oliver Kiddle [this message]
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22530-1678390068.958410@dJKq.2wyk.2KSv \
--to=opk@zsh.org \
--cc=eliasghafari@disroot.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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
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).