fish_git_prompt: fix buggy rename parsing

Commit f86c9af455 (fish_git_prompt: skip rename/copy source paths in
status parsing, 2026-05-12).  filters from "git-status --porcelain"
output all lines that don't look like a status entry.  This is
to filter out the rename source path.  But the filtering has false
positives, e.g. if a rename source path starts with "AA".  Let's only
skip lines immediately after each rename entry.  Also for copy (C)
though I haven't found a test case for that yet.
This commit is contained in:
Johannes Altmanninger
2026-05-14 00:17:12 +08:00
parent ee4eea51ec
commit 5876ff66ff

View File

@@ -408,9 +408,17 @@ end
### helper functions
function __fish_git_prompt_status_porcelain_modulo_rename_source
git -c core.fsmonitor= status --porcelain -z $argv |
string split0 |
string match -r '^[ MADRCTU?!]{2} .*'
set -l skip false
for line in (git -c core.fsmonitor= status --porcelain -z $argv | string split0)
if $skip
set skip false
continue
end
printf %s\n $line
if string match -rq -- ^[RC] $line
set skip true
end
end
end
function __fish_git_prompt_informative_status