aboutsummaryrefslogtreecommitdiff
path: root/gitstatus.plugin.sh
diff options
context:
space:
mode:
authorRoman Perepelitsa <roman.perepelitsa@gmail.com>2021-06-10 11:15:02 +0300
committerRoman Perepelitsa <roman.perepelitsa@gmail.com>2021-06-10 11:15:02 +0300
commit96f3ca173331c5dba505d2ef5106cb0d605ec3be (patch)
tree4fde241e52a4a67976c46e18bad36f7d0a869e15 /gitstatus.plugin.sh
parentba83466e1da75d9260ebbb145215d9c46d6eadf6 (diff)
Squashed 'gitstatus/' changes from 113f1f69..96b520b2
96b520b2 build v1.5.1 binaries for all platforms ffeb0507 bump version to v1.5.1 1bcbea07 mbuild: disable pacman upgrades on msys 39dbb92f log a warning if unable to parse packed-refs a9d70ec0 add `-r` flag to gitstatus_start in bash bindings (#241) abbf9a79 don't use static_assert with one argument as it's not available prior to c++17 (#239) f8c396e4 drop all tags if packed-refs doesn't have a header line (https://github.com/romkatv/powerlevel10k/issues/1428) git-subtree-dir: gitstatus git-subtree-split: 96b520b248ca872646e27b3df4535898356e4637
Diffstat (limited to 'gitstatus.plugin.sh')
-rw-r--r--gitstatus.plugin.sh11
1 files changed, 9 insertions, 2 deletions
diff --git a/gitstatus.plugin.sh b/gitstatus.plugin.sh
index 95c5402e..9a75cb5f 100644
--- a/gitstatus.plugin.sh
+++ b/gitstatus.plugin.sh
@@ -35,6 +35,11 @@
#
# -D Unless this option is specified, report zero staged, unstaged and conflicted
# changes for repositories with bash.showDirtyState = false.
+#
+# -r INT Close git repositories that haven't been used for this many seconds. This is
+# meant to release resources such as memory and file descriptors. The next request
+# for a repo that's been closed is much slower than for a repo that hasn't been.
+# Negative value means infinity. The default is 3600 (one hour).
function gitstatus_start() {
if [[ "$BASH_VERSION" < 4 ]]; then
>&2 printf 'gitstatus_start: need bash version >= 4.0, found %s\n' "$BASH_VERSION"
@@ -48,10 +53,10 @@ function gitstatus_start() {
fi
unset OPTIND
- local opt timeout=5 max_dirty=-1 extra_flags
+ local opt timeout=5 max_dirty=-1 ttl=3600 extra_flags
local max_num_staged=1 max_num_unstaged=1 max_num_conflicted=1 max_num_untracked=1
local ignore_status_show_untracked_files
- while getopts "t:s:u:c:d:m:eUWD" opt; do
+ while getopts "t:s:u:c:d:m:r:eUWD" opt; do
case "$opt" in
t) timeout=$OPTARG;;
s) max_num_staged=$OPTARG;;
@@ -59,6 +64,7 @@ function gitstatus_start() {
c) max_num_conflicted=$OPTARG;;
d) max_num_untracked=$OPTARG;;
m) max_dirty=$OPTARG;;
+ r) ttl=$OPTARG;;
e) extra_flags+='--recurse-untracked-dirs ';;
U) extra_flags+='--ignore-status-show-untracked-files ';;
W) extra_flags+='--ignore-bash-show-untracked-files ';;
@@ -113,6 +119,7 @@ function gitstatus_start() {
--max-num-conflicted="$max_num_conflicted"
--max-num-untracked="$max_num_untracked"
--dirty-max-index-size="$max_dirty"
+ --repo-ttl-seconds="$ttl"
$extra_flags)
tmpdir="$(command mktemp -d "${TMPDIR:-/tmp}"/gitstatus.bash.$$.XXXXXXXXXX)" || return