Skip to content

Comments

_git: fix --git-dir and --work-tree options when used with parameters#156

Open
baodrate wants to merge 1 commit intozsh-users:masterfrom
baodrate:_git
Open

_git: fix --git-dir and --work-tree options when used with parameters#156
baodrate wants to merge 1 commit intozsh-users:masterfrom
baodrate:_git

Conversation

@baodrate
Copy link

_arguments sets opt_args with the un-expanded values from the command line. So the GIT_DIR/GIT_WORK_TREE environment variables are set non-functional when those options contain parameters. e.g.:

expand-or-complete

opt_args=(
  [--git-dir]='$HOME/.dotfiles'
  [--work-tree]='$HOME'
)
...
local -x GIT_DIR='$HOME/.dotfiles'
local -x GIT_WORK_TREE='$HOME'

files=(${(0)"$(_call_program files git ...)"})
fatal: not a git repository: '$HOME/.dotfiles'

Expand these two opts when setting so that they function as intended.

`_arguments` sets opt_args with the un-expanded values from the command line.
So the `GIT_DIR`/`GIT_WORK_TREE` environment variables are set non-functional
when those options contain parameters. e.g.:

```zsh
expand-or-complete

opt_args=(
  [--git-dir]='$HOME/.dotfiles'
  [--work-tree]='$HOME'
)
...
local -x GIT_DIR='$HOME/.dotfiles'
local -x GIT_WORK_TREE='$HOME'

files=(${(0)"$(_call_program files git ...)"})
fatal: not a git repository: '$HOME/.dotfiles'
```

Expand these two opts when setting so that they function as intended.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant