git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "D. Ben Knoble" <ben.knoble@gmail.com>
To: Git <git@vger.kernel.org>
Cc: "felipe.contreras@gmail.com" <felipe.contreras@gmail.com>
Subject: Zsh completion: cached __git_repo_path affects shell session, breaks completion
Date: Wed, 24 Apr 2024 09:46:37 -0400	[thread overview]
Message-ID: <CALnO6CBv3+e2WL6n6Mh7ZZHCX2Ni8GpvM4a-bQYxNqjmgZdwdg@mail.gmail.com> (raw)

I can only reproduce this in Zsh, not with Bash (using equivalent
commands), though the caching behavior comes from Bash (fad9484f0a
(completion: cache the path to the repository, 2017-02-03)).

For example (with Zsh):

mkdir a b b/c
for d (a b); git -C $d init && git -C $d commit --allow-empty -m init
cd a
git branch foo
pushd ../b/c
git branch bar
git rebase <TAB>… # completion for bar available; C-c to abort
declare -p __git_repo_path # outputs /path/to/b/.git
popd
git branch # outputs foo, main
git rebase <TAB>… # completion candidates are bar, main!

I've only been able to observe this with rebase so far (e.g., using
switch instead doesn't seem to trigger the problem).

I wonder if all callers of __git_find_repo_path should declare `local
__git_repo_path`? That might defeat some caching, but I don't think
__git_repo_path should be set globally in a shell session, and the
script is explicitly intended to be sourced… again, though, I think
Bash does the correct thing and somehow Zsh is capturing this variable
that it shouldn't be.

-- 
D. Ben Knoble


                 reply	other threads:[~2024-04-24 13:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALnO6CBv3+e2WL6n6Mh7ZZHCX2Ni8GpvM4a-bQYxNqjmgZdwdg@mail.gmail.com \
    --to=ben.knoble@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.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://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).