diff options
| author | Matt Hunter <m@lfurio.us> | 2026-03-30 23:53:25 -0400 |
|---|---|---|
| committer | Matt Hunter <m@lfurio.us> | 2026-04-22 21:59:29 -0400 |
| commit | 034ca9256a06a3b384343f722a96219908d356df (patch) | |
| tree | a9bba4f1d38b950e851a5b4f0eb15fd031866c3c | |
| parent | 4f88708af94e82e7f8da427d7f3c6a876acbd71a (diff) | |
| download | git-sonar-034ca9256a06a3b384343f722a96219908d356df.tar.gz git-sonar-034ca9256a06a3b384343f722a96219908d356df.zip | |
Only invoke git-precheck once
Cache the exit code from git-precheck to be used later by the condition
feature. Ensure git-precheck is run with the --ignore-dirty and
--ignore-untracked options, to avoid an unnecessary call to git-status.
Signed-off-by: Matt Hunter <m@lfurio.us>
| -rwxr-xr-x | git-sonar | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -41,11 +41,6 @@ prepare_colors() { } -is_repo() { - git-precheck --quiet - [ $? -lt 4 ] -} - fetch() { FETCH_TIME="${GIT_RADAR_FETCH_TIME:-"$((5 * 60))"}" TS_FILE="$(git rev-parse --git-path lastupdatetime 2>/dev/null)" @@ -327,8 +322,7 @@ stash_status() { } repo_special_condition() { - git-precheck --quiet --ignore-dirty --ignore-untracked \ - || printf "$COLOR_CONDITION!$RESET_COLOR_CONDITION" + [ "$precheck_status" -lt 3 ] || printf '%b' "$COLOR_CONDITION!$RESET_COLOR" } render_prompt() { @@ -487,8 +481,11 @@ if [ $# -ne 0 ]; then exit 1 fi -# Guard all active operations by this is_repo check -if is_repo; then +git-precheck --quiet --ignore-dirty --ignore-untracked >/dev/null 2>&1 +precheck_status=$? + +# Guard all active operations by this "is in repo" check +if [ "$precheck_status" -lt 4 ]; then # Merge configuration from accepted RC files [ -f "$HOME/.gitradarrc" ] && . "$HOME/.gitradarrc" [ -f "$HOME/.gitradarrc.bash" ] && . "$HOME/.gitradarrc.bash" |
