summaryrefslogtreecommitdiff
path: root/01_Functions.zsh
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2008-06-12 17:56:51 +0200
committerHugues Hiegel <hugues@hiegel.fr>2008-06-13 11:34:49 +0200
commit0389ee35965add0d260f83cd145cb6fe20016aa2 (patch)
tree0c893e93f10c0c01525a541e96e37d54ad050515 /01_Functions.zsh
parent1a0b3979930861b6f8eabbcc9f4d6bd675ab957b (diff)
Anti-concurrential git-status for prompt update...
When a .git folder contains to many blobs and takes too long time to get the status, instead of hanging up every shell, just let one of these (the first, of course) getting the current git status, the others will take the previous one, else a 'running' color status.
Diffstat (limited to '01_Functions.zsh')
-rw-r--r--01_Functions.zsh25
1 files changed, 25 insertions, 0 deletions
diff --git a/01_Functions.zsh b/01_Functions.zsh
index d4c77bf..be04aba 100644
--- a/01_Functions.zsh
+++ b/01_Functions.zsh
@@ -84,6 +84,27 @@ get_git_branch ()
get_git_status ()
{
local my_git_status cached not_up_to_date managment_folder
+ local lockfile previous
+
+ lockfile="$(git rev-parse --git-dir)/.zsh.get_git_status.lock"
+ previous="$(git rev-parse --git-dir)/.zsh.get_git_status.prev"
+
+ if [ -e $lockfile ] ; then
+
+ my_git_status=$git_colors[running]
+
+ [ "$DEBUG" == "yes" ] && echo >&2 "lockfile $lockfile already present.."
+ if [ -e $previous ] ; then
+ [ "$DEBUG" == "yes" ] && eecho >&2 "getting previous status.."
+ my_git_status=$(cat $previous)
+ fi
+
+ echo $my_git_status
+ return
+ fi
+
+ [ "$DEBUG" == "yes" ] && echo >&2 "creating $lockfile.."
+ touch $lockfile
if [ "$(git-rev-parse --git-dir)" == "." ] ; then
echo "$git_colors[managment_folder]"
@@ -107,6 +128,10 @@ get_git_status ()
my_git_status="$git_colors[up_to_date]"
fi
+ [ "$DEBUG" == "yes" ] && echo >&2 "removing $lockfile.."
+ echo $my_git_status > $previous
+ rm -f $lockfile
+
echo $my_git_status
}