Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
71201ffd
Commit
71201ffd
authored
Sep 05, 2016
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git: output nothing when no commits ahead or behind
This fixes old git_commits_ahead behavior and changes git_commits_behind to have the same behavior. Fixes #5355
parent
298b6351
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
git.zsh
lib/git.zsh
+10
-5
No files found.
lib/git.zsh
View file @
71201ffd
...
@@ -76,16 +76,21 @@ function git_current_branch() {
...
@@ -76,16 +76,21 @@ function git_current_branch() {
# Gets the number of commits ahead from remote
# Gets the number of commits ahead from remote
function
git_commits_ahead
()
{
function
git_commits_ahead
()
{
if
$(
command
git rev-parse
--git-dir
>
/dev/null 2>&1
)
;
then
if
command
git rev-parse
--git-dir
&>/dev/null
;
then
local
COMMITS
=
"
$(
git rev-list
--count
@
{
upstream
}
..HEAD
)
"
local
commits
=
"
$(
git rev-list
--count
@
{
upstream
}
..HEAD
)
"
echo
"
$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX
"
if
[[
"
$commits
"
!=
0
]]
;
then
echo
"
$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX
"
fi
fi
fi
}
}
# Gets the number of commits behind remote
# Gets the number of commits behind remote
function
git_commits_behind
()
{
function
git_commits_behind
()
{
if
$(
command
git rev-parse
--git-dir
>
/dev/null 2>&1
)
;
then
if
command
git rev-parse
--git-dir
&>/dev/null
;
then
echo
$(
git rev-list
--count
HEAD..@
{
upstream
}
)
local
commits
=
"
$(
git rev-list
--count
HEAD..@
{
upstream
}
)
"
if
[[
"
$commits
"
!=
0
]]
;
then
echo
"
$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX
"
fi
fi
fi
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment