Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...)
- X-seq: zsh-workers 52136
- From: eliasghafari <eliasghafari@xxxxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...)
- Date: Tue, 12 Sep 2023 22:25:35 +0300
- Archived-at: <https://zsh.org/workers/52136>
- In-reply-to: <CAN=4vMpe3NYqYTHiOp+ApRhfZ6EYEhXygVTE5hMP0uTtRr16og@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <jayiekgd7doualsehpteuujj5cq4g5cuggfj7q72vsxaluacmd@wavkea46lupk> <CAN=4vMpe3NYqYTHiOp+ApRhfZ6EYEhXygVTE5hMP0uTtRr16og@mail.gmail.com>
On 23/09/12 11:34AM, Roman Perepelitsa wrote:
> Given these two definitions that differ only in quotes:
>
> alias c1="git --git-dir=$HOME/.local/share/dotfiles --work-tree $HOME"
> alias c2='git --git-dir=$HOME/.local/share/dotfiles --work-tree $HOME'
>
> Can you confirm that the following two commands work as expected?
>
> c1 diff
> c2 diff
Yes they both work and give the info they're supposed to give.
> Can you furthermore confirm that only the first of the following works
> as expected while the second does not?
>
> c1 diff <TAB>
> c2 diff <TAB>
Also yes c1 autocompletion works perfectly, while c2 doesn't.
For further info during my reading of the log produced by `config diff
<C-x ?>` I noticed a couple of things, which if you want to investigate
this, it might help you out.
Using this alias: 'git --git-dir=$HOME/.local/share/dotfiles --work-tree ~'
+_git:64> local -x GIT_DIR='$HOME/.local/share/dotfiles'
Notice that $HOME is not expanded, notice that the path is surrounded
by ''
+(eval):1> git --no-pager rev-list -20 '--format=%h%n%d%n%s (%cr)%n%p' HEAD
fatal: not a git repository: '$HOME/.local/share/dotfiles'
GIT_DIR not being expanded makes the autocompletion error out here where
git doesn't recognize the path as a git dir, but the command itself does
work if I `config status` it will give me the expected output. So the
conclusion is that $HOME is not being expanded in GIT_DIR but is
expanded in the command line (maybe ?).
Using this alias: 'git --git-dir=~/.local/share/dotfiles --work-tree ~'
+_git:64> local -x GIT_DIR=/home/elias/.local/share/dotfiles
Notice ~ got expanded, and autocompletion works perfectly, but this time
the command doesn't work it gives this error:
warning: Not a git repository. Use --no-index to compare two paths outside a working tree
So the ~ in GIT_DIR is being expanded but in the command line it's not.
And like I said 'git --git-dir ~/.local/share/dotfiles --work-tree ~'
both works with autocompletion and the command line.
One last thing with config='git --git-dir ~/.local/share/dotfiles --work-tree ~'
if I do `alias config` to show what the alias is set to, the output is
exactly the same as above config=...
But with config="git --git-dir=$HOME/.local/share/dotfiles --work-tree $HOME"
alias config outputs:
config='git --git-dir=/home/elias/.local/share/dotfiles --work-tree /home/elias'
Which is interesting it's already expanded that might why it's working.
Anyways hope this helps!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author