From f69f074f6607c181c8079512f3679ec5adfa710b Mon Sep 17 00:00:00 2001 From: June Kim Date: Tue, 12 May 2026 21:09:41 -0700 Subject: [PATCH] Add failing test for git prompt rename miscount (issue #11296) git status --porcelain -z outputs the rename source filename as a separate NUL-delimited entry after the status line. When the source filename starts with [ACDMRTU], the informative prompt miscounts it as an additional staged change. Part of #12754 --- tests/checks/git.fish | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/checks/git.fish b/tests/checks/git.fish index 06fbc7efc..aec81ac15 100644 --- a/tests/checks/git.fish +++ b/tests/checks/git.fish @@ -161,6 +161,26 @@ echo set -e __fish_git_prompt_showdirtystate +# Test that renames count as one staged change, not two (issue #11296). +# git status --porcelain -z outputs rename source as a separate NUL-delimited field, +# which should not be counted as an additional change. +# Use a filename starting with R (in [ACDMRTU]) to trigger the miscount. +git -c user.email=banana@example.com -c user.name=banana commit -m 'commit staged foo' >/dev/null +echo content >Rfile +git add Rfile +git -c user.email=banana@example.com -c user.name=banana commit -m 'add Rfile' >/dev/null + +set -g __fish_git_prompt_show_informative_status 1 +mkdir -p subdir +git mv Rfile subdir/Rfile +fish_git_prompt +echo +#CHECK: (newbranch|●1) +git reset >/dev/null 2>&1 +mv subdir/Rfile Rfile +rmdir subdir +set -e __fish_git_prompt_show_informative_status + # Test displaying only stash count set -g __fish_git_prompt_show_informative_status 1 set -g __fish_git_prompt_showstashstate 1