summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorKat R. <signe@users.noreply.github.com>2025-04-19 10:49:16 -0700
committerGitHub <noreply@github.com>2025-04-19 19:49:16 +0200
commita7426f0b38817bf7cd7000a5d378b7cfb059884f (patch)
treef7b74259bb0a646ce3cf618d9d5c1d5a49b5a730 /plugins
parentc1e5ff31693f391a0bbb30b12c8e7bc1cc976b7b (diff)
downloadzsh-a7426f0b38817bf7cd7000a5d378b7cfb059884f.tar.gz
zsh-a7426f0b38817bf7cd7000a5d378b7cfb059884f.tar.bz2
zsh-a7426f0b38817bf7cd7000a5d378b7cfb059884f.zip
fix(git-prompt): use `--git-common-dir` to load stash count (#13072)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/git-prompt/gitstatus.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py
index 94774d828..7cd8f54e2 100644
--- a/plugins/git-prompt/gitstatus.py
+++ b/plugins/git-prompt/gitstatus.py
@@ -23,9 +23,10 @@ def get_tagname_or_hash():
return hash_
return None
-# Re-use method from https://github.com/magicmonty/bash-git-prompt to get stashs count
+# Re-use method from https://github.com/magicmonty/bash-git-prompt to get stash count
+# Use `--git-common-dir` to avoid problems with git worktrees, which don't have individual stashes
def get_stash():
- cmd = Popen(['git', 'rev-parse', '--git-dir'], stdout=PIPE, stderr=PIPE)
+ cmd = Popen(['git', 'rev-parse', '--git-common-dir'], stdout=PIPE, stderr=PIPE)
so, se = cmd.communicate()
stash_file = '%s%s' % (so.decode('utf-8').rstrip(), '/logs/refs/stash')
@@ -35,7 +36,6 @@ def get_stash():
except IOError:
return 0
-
# `git status --porcelain --branch` can collect all information
# branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind
po = Popen(['git', 'status', '--porcelain', '--branch'], env=dict(os.environ, LANG="C"), stdout=PIPE, stderr=PIPE)