zsh-workers
 help / color / mirror / code / Atom feed
From: eliasghafari <eliasghafari@disroot.org>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: [BUG]Filename autocompletion using git-bare repos (--git-dir=... --work-tree=...)
Date: Tue, 12 Sep 2023 22:25:35 +0300	[thread overview]
Message-ID: <wacpbrdxdhaaxzzenf4ocl63lklpod5v6sjvbgfywcz2o5xrna@q6bp3dzafenl> (raw)
In-Reply-To: <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!


  reply	other threads:[~2023-09-12 19:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12  8:54 eliasghafari
2023-09-12  9:34 ` Roman Perepelitsa
2023-09-12 19:25   ` eliasghafari [this message]
2023-09-12 19:33     ` Roman Perepelitsa
  -- strict thread matches above, loose matches on Subject: below --
2023-03-09 12:33 eliasghafari
2023-03-09 17:12 ` Bart Schaefer
2023-03-09 19:27 ` Oliver Kiddle
2023-03-10 10:07   ` Elias Ghafari
2023-03-10 10:12     ` Roman Perepelitsa
2023-09-11 15:05       ` Elias Ghafari
2023-09-12  2:26         ` Jun T

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=wacpbrdxdhaaxzzenf4ocl63lklpod5v6sjvbgfywcz2o5xrna@q6bp3dzafenl \
    --to=eliasghafari@disroot.org \
    --cc=roman.perepelitsa@gmail.com \
    --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).