Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash completion does not invalidate cached __git_repo_path variable #1018

Closed
rohieb opened this issue Jun 16, 2020 · 2 comments
Closed

bash completion does not invalidate cached __git_repo_path variable #1018

rohieb opened this issue Jun 16, 2020 · 2 comments

Comments

@rohieb
Copy link

rohieb commented Jun 16, 2020

Steps to reproduce:

  1. cd into a git repository
  2. type tig <Tab>
  3. change into another git repository
  4. type tig <Tab> again

Expected behaviour:

  • in step 4, the tig completion completes refs from the current repository

Actual behaviour:

  • in step 4, the tig completion completes refs from the previous repository, not the current one

This is because the tig completion uses internals from the git completion, which caches the path to the git directory in the shell variable __git_repo_path. Inside the git completion, this variable is defined on the local call stack in __git_main(), but in the tig completion, this variable is not defined, so the variable stays global and is cached in the current shell session.

Workaround:

  • unset __git_repo_path after changing to another repo

Reminder to myself to refactor the tig bash completion so it stays more independent from the git-completion's internals… (I cannot assign myself to this issue because I'm not a maintainer, so feel free to do so.)

@rohieb
Copy link
Author

rohieb commented Jun 16, 2020

Ah, apparently this is only a problem when the git repo is not .git, because in this case $__git_repo_path will be correct nevertheless. However, when using worktrees, the repo path can be something like ~/projects/linux/.git/worktrees/linux-maint, which will cause problems.

@rohieb
Copy link
Author

rohieb commented Jan 3, 2021

@koutcher oh, thanks, I forgot about this!

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

No branches or pull requests

1 participant