fix(mortalscumbag): compare against the tracked branch, not origin (#14265)

The ahead/behind markers compared HEAD with `origin/<branch>`, so in a
fork where the branch tracks a different remote they reported the
difference to `origin` instead of to the branch's own upstream. Use
`@{upstream}`, like `git_commits_ahead`/`git_commits_behind` in
lib/git.zsh do. A branch without an upstream shows no marker.
This commit is contained in:
Julian Oes authored and GitHub committed 2026-11-22 10:09:30 -08:00
1 parent 902761f897
commit 3ecde00d94
1 file changed
+2 -2
+2 -2
View File
@@ -5,12 +5,12 @@ function my_git_prompt() {
STATUS=""
# is branch ahead?
if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
if $(echo "$(git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
# is branch behind?
if $(echo "$(git log HEAD..origin/$(git_current_branch) 2> /dev/null)" | grep '^commit' &> /dev/null); then
if $(echo "$(git log HEAD..@{upstream} 2> /dev/null)" | grep '^commit' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
fi