mirror of
https://github.com/IlanCosman/tide.git
synced 2024-11-26 09:42:51 +03:00
Always fetch git status, even in .git dir
This commit is contained in:
parent
73f0e6dbab
commit
21d57439dd
@ -1,18 +1,9 @@
|
|||||||
function _tide_item_git
|
function _tide_item_git
|
||||||
# Branch or SHA
|
# Branch or SHA
|
||||||
set -l branch (git branch --show-current 2>/dev/null) || return
|
set -l branch (git branch --show-current 2>/dev/null) || return
|
||||||
# --quiet ensures that it won't complain if there are no commits
|
# --quiet=don't complain if there are no commits
|
||||||
git rev-parse --quiet --is-inside-work-tree --git-dir --short HEAD |
|
git rev-parse --quiet --git-dir --short HEAD | read --local --line gitDir location
|
||||||
read --local --line isInsideWorkTree gitDir sha
|
test -n "$branch" && set location $branch # location is SHA if branch is empty
|
||||||
|
|
||||||
set -l location
|
|
||||||
if test "$isInsideWorkTree" = false
|
|
||||||
set location GIT_DIR!
|
|
||||||
else if test -n "$branch"
|
|
||||||
set location $branch
|
|
||||||
else
|
|
||||||
set location $sha
|
|
||||||
end
|
|
||||||
|
|
||||||
# Operation
|
# Operation
|
||||||
set -l operation
|
set -l operation
|
||||||
@ -54,20 +45,12 @@ function _tide_item_git
|
|||||||
test "$upstreamAhead" = 0 && set -e upstreamAhead
|
test "$upstreamAhead" = 0 && set -e upstreamAhead
|
||||||
|
|
||||||
# Git status/stash
|
# Git status/stash
|
||||||
set -l staged
|
set -l gitInfo (git -C $gitDir/.. status --porcelain)
|
||||||
set -l dirty
|
set -l staged (string match --regex '^[ADMR].' $gitInfo | count) || set -e staged
|
||||||
set -l untracked
|
set -l dirty (string match --regex '^.[ADMR]' $gitInfo | count) || set -e dirty
|
||||||
set -l conflicted
|
set -l untracked (string match --regex '^\?\?' $gitInfo | count) || set -e untracked
|
||||||
set -l stash
|
set -l conflicted (string match --regex '^UU' $gitInfo | count) || set -e conflicted
|
||||||
|
set -l stash (git -C $gitDir/.. stash list | count) || set -e stash
|
||||||
if test "$isInsideWorkTree" = true
|
|
||||||
set -l gitInfo (git status --porcelain)
|
|
||||||
set staged (string match --regex '^[ADMR].' $gitInfo | count) || set -e staged
|
|
||||||
set dirty (string match --regex '^.[ADMR]' $gitInfo | count) || set -e dirty
|
|
||||||
set untracked (string match --regex '^\?\?' $gitInfo | count) || set -e untracked
|
|
||||||
set conflicted (string match --regex '^UU' $gitInfo | count) || set -e conflicted
|
|
||||||
set stash (git stash list | count) || set -e stash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Print the information
|
# Print the information
|
||||||
printf '%s' \
|
printf '%s' \
|
||||||
|
@ -50,7 +50,3 @@ _git commit -am 'Append hello to foo'
|
|||||||
# SHA
|
# SHA
|
||||||
_git checkout HEAD~
|
_git checkout HEAD~
|
||||||
_git_item # CHECK: {{\w*}}
|
_git_item # CHECK: {{\w*}}
|
||||||
|
|
||||||
# GIT_DIR!
|
|
||||||
cd .git
|
|
||||||
_git_item # CHECK: GIT_DIR!
|
|
||||||
|
Loading…
Reference in New Issue
Block a user