Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speed up obtaining VCS branch. #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions autoload/promptline/slices/vcs_branch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ fun! promptline#slices#vcs_branch#function_body(options)
let fossil = get(a:options, 'fossil', 0)

let lines = [
\'function __promptline_vcs_test() {',
\' local dir="$(pwd -P 2>/dev/null)"',
\' while [[ -n $dir ]]; do',
\' if test "$1" "$dir/$2"; then',
\' return 0',
\' fi',
\' dir=${dir%/*}',
\' done',
\' return 0',
\'}',
\'function __promptline_vcs_branch {',
\' local branch',
\' local branch_symbol="' . branch_symbol . '"']
Expand All @@ -14,7 +24,7 @@ fun! promptline#slices#vcs_branch#function_body(options)
let lines += [
\'',
\' # git',
\' if hash git 2>/dev/null; then',
\' if hash git 2>/dev/null && __promptline_vcs_test -e .git; then',
\' if branch=$( { git symbolic-ref --quiet HEAD || git rev-parse --short HEAD; } 2>/dev/null ); then',
\' branch=${branch##*/}',
\' printf "%s" "${branch_symbol}${branch:-unknown}"',
Expand All @@ -27,7 +37,7 @@ fun! promptline#slices#vcs_branch#function_body(options)
let lines += [
\'',
\' # mercurial',
\' if hash hg 2>/dev/null; then',
\' if hash hg 2>/dev/null && __promptline_vcs_test -e .hg; then',
\' if branch=$(hg branch 2>/dev/null); then',
\' printf "%s" "${branch_symbol}${branch:-unknown}"',
\' return',
Expand All @@ -39,7 +49,7 @@ fun! promptline#slices#vcs_branch#function_body(options)
let lines += [
\'',
\' # svn',
\' if hash svn 2>/dev/null; then',
\' if hash svn 2>/dev/null && __promptline_vcs_test -e .svn; then',
\' local svn_info',
\' if svn_info=$(svn info 2>/dev/null); then',
\' local svn_url=${svn_info#*URL:\ }',
Expand Down Expand Up @@ -67,7 +77,7 @@ fun! promptline#slices#vcs_branch#function_body(options)
let lines += [
\'',
\' # fossil',
\' if hash fossil 2>/dev/null; then',
\' if hash fossil 2>/dev/null && __promptline_vcs_test -f .fslckout; then',
\' if branch=$( fossil branch 2>/dev/null ); then',
\' branch=${branch##* }',
\' printf "%s" "${branch_symbol}${branch:-unknown}"',
Expand Down