mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Update __fish_git_prompt.fish to use 'else if'
This commit is contained in:
parent
3f8baeba20
commit
32b2c9fc9e
|
@ -157,10 +157,8 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
|
||||||
set upstream (/bin/sh -c 'echo "${1%/$2}"' -- $pattern $trunk)/$upstream
|
set upstream (/bin/sh -c 'echo "${1%/$2}"' -- $pattern $trunk)/$upstream
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else if test $upstream = svn+git
|
||||||
if test $upstream = svn+git
|
set upstream '@{upstream}'
|
||||||
set upstream '@{upstream}'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -225,51 +223,46 @@ function __fish_git_prompt --description "Prompt function for Git"
|
||||||
if test -f $git_dir/rebase-merge/interactive
|
if test -f $git_dir/rebase-merge/interactive
|
||||||
set r "|REBASE-i"
|
set r "|REBASE-i"
|
||||||
set b (cat $git_dir/rebase-merge/head-name)
|
set b (cat $git_dir/rebase-merge/head-name)
|
||||||
else; if test -d $git_dir/rebase-merge
|
else if test -d $git_dir/rebase-merge
|
||||||
set r "|REBASE-m"
|
set r "|REBASE-m"
|
||||||
set b (cat $git_dir/rebase-merge/head-name)
|
set b (cat $git_dir/rebase-merge/head-name)
|
||||||
else
|
else
|
||||||
if test -d $git_dir/rebase-apply
|
if test -d $git_dir/rebase-apply
|
||||||
if test -f $git_dir/rebase-apply/rebasing
|
if test -f $git_dir/rebase-apply/rebasing
|
||||||
set r "|REBASE"
|
set r "|REBASE"
|
||||||
else; if test -f $git_dir/rebase-apply/applying
|
else if test -f $git_dir/rebase-apply/applying
|
||||||
set r "|AM"
|
set r "|AM"
|
||||||
else
|
else
|
||||||
set r "|AM/REBASE"
|
set r "|AM/REBASE"
|
||||||
end
|
|
||||||
end
|
|
||||||
else; if test -f $git_dir/MERGE_HEAD
|
|
||||||
set r "|MERGING"
|
|
||||||
else; if test -f $git_dir/CHERRY_PICK_HEAD
|
|
||||||
set r "|CHERRY-PICKING"
|
|
||||||
else; if test -f $git_dir/BISECT_LOG
|
|
||||||
set r "|BISECTING"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
else if test -f $git_dir/MERGE_HEAD
|
||||||
|
set r "|MERGING"
|
||||||
|
else if test -f $git_dir/CHERRY_PICK_HEAD
|
||||||
|
set r "|CHERRY-PICKING"
|
||||||
|
else if test -f $git_dir/BISECT_LOG
|
||||||
|
set r "|BISECTING"
|
||||||
|
end
|
||||||
|
|
||||||
set -l os
|
set -l os
|
||||||
set b (git symbolic-ref HEAD ^/dev/null; set os $status)
|
set b (git symbolic-ref HEAD ^/dev/null; set os $status)
|
||||||
|
if test $os -ne 0
|
||||||
|
set b (switch "$__fish_git_prompt_describe_style"
|
||||||
|
case contains
|
||||||
|
git describe --contains HEAD
|
||||||
|
case branch
|
||||||
|
git describe --contains --all HEAD
|
||||||
|
case describe
|
||||||
|
git describe HEAD
|
||||||
|
case default '*'
|
||||||
|
git describe --tags --exact-match HEAD
|
||||||
|
end ^/dev/null; set os $status)
|
||||||
if test $os -ne 0
|
if test $os -ne 0
|
||||||
set b (switch "$__fish_git_prompt_describe_style"
|
set b (cut -c1-7 $git_dir/HEAD ^/dev/null; set os $status)
|
||||||
case contains
|
|
||||||
git describe --contains HEAD
|
|
||||||
case branch
|
|
||||||
git describe --contains --all HEAD
|
|
||||||
case describe
|
|
||||||
git describe HEAD
|
|
||||||
case default '*'
|
|
||||||
git describe --tags --exact-match HEAD
|
|
||||||
end ^/dev/null; set os $status)
|
|
||||||
if test $os -ne 0
|
if test $os -ne 0
|
||||||
set b (cut -c1-7 $git_dir/HEAD ^/dev/null; set os $status)
|
set b unknown
|
||||||
if test $os -ne 0
|
|
||||||
set b unknown
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
set b "($b)"
|
|
||||||
end
|
end
|
||||||
|
set b "($b)"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -288,32 +281,31 @@ function __fish_git_prompt --description "Prompt function for Git"
|
||||||
else
|
else
|
||||||
set b "GIT_DIR!"
|
set b "GIT_DIR!"
|
||||||
end
|
end
|
||||||
else; if test "true" = (git rev-parse --is-inside-work-tree ^/dev/null)
|
else if test "true" = (git rev-parse --is-inside-work-tree ^/dev/null)
|
||||||
if test -n "$__fish_git_prompt_showdirtystate"
|
if test -n "$__fish_git_prompt_showdirtystate"
|
||||||
set -l config (git config --bool bash.showDirtyState)
|
set -l config (git config --bool bash.showDirtyState)
|
||||||
if test "$config" != "false"
|
if test "$config" != "false"
|
||||||
git diff --no-ext-diff --quiet --exit-code; or set w $___fish_git_prompt_char_dirtystate
|
git diff --no-ext-diff --quiet --exit-code; or set w $___fish_git_prompt_char_dirtystate
|
||||||
if git rev-parse --quiet --verify HEAD >/dev/null
|
if git rev-parse --quiet --verify HEAD >/dev/null
|
||||||
git diff-index --cached --quiet HEAD --; or set i $___fish_git_prompt_char_stagedstate
|
git diff-index --cached --quiet HEAD --; or set i $___fish_git_prompt_char_stagedstate
|
||||||
else
|
else
|
||||||
set i $___fish_git_prompt_char_invalidstate
|
set i $___fish_git_prompt_char_invalidstate
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if test -n "$__fish_git_prompt_showstashstate"
|
end
|
||||||
git rev-parse --verify refs/stash >/dev/null ^&1; and set s $___fish_git_prompt_char_stashstate
|
if test -n "$__fish_git_prompt_showstashstate"
|
||||||
end
|
git rev-parse --verify refs/stash >/dev/null ^&1; and set s $___fish_git_prompt_char_stashstate
|
||||||
|
end
|
||||||
|
|
||||||
if test -n "$__fish_git_prompt_showuntrackedfiles"
|
if test -n "$__fish_git_prompt_showuntrackedfiles"
|
||||||
set -l files (git ls-files --others --exclude-standard)
|
set -l files (git ls-files --others --exclude-standard)
|
||||||
if test -n "$files"
|
if test -n "$files"
|
||||||
set u $___fish_git_prompt_char_untrackedfiles
|
set u $___fish_git_prompt_char_untrackedfiles
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if test -n "$__fish_git_prompt_showupstream"
|
if test -n "$__fish_git_prompt_showupstream"
|
||||||
set p (__fish_git_prompt_show_upstream)
|
set p (__fish_git_prompt_show_upstream)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user