diff options
| author | Matt Hunter <m@lfurio.us> | 2026-05-06 03:48:53 -0400 |
|---|---|---|
| committer | Matt Hunter <m@lfurio.us> | 2026-05-08 03:53:48 -0400 |
| commit | 5d17b0508e7957b873301357157945bf2dfe2d42 (patch) | |
| tree | db06e302065ed6634929b656ffd93619e77968fa | |
| parent | c336acfc57bd408dcb93379a171270612c3f1cd3 (diff) | |
| download | git-sonar-5d17b0508e7957b873301357157945bf2dfe2d42.tar.gz git-sonar-5d17b0508e7957b873301357157945bf2dfe2d42.zip | |
Use faster command to obtain stash count
Using git-rev-list, we can directly return a count of stashes without
the need for additional external calls like wc.
As a result, the line_count helper function is now unused, so remove it.
Signed-off-by: Matt Hunter <m@lfurio.us>
Diffstat (limited to '')
| -rwxr-xr-x | git-sonar | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -114,13 +114,6 @@ determine_default_branch() { done } -line_count() { - # macos 'wc' produces odd formatting (extra spaces) - # The grep is present to deal with this, filter out cases where the count - # is zero, and provide a return value (true if count is non-zero). - wc -l 2>/dev/null | grep -oE '[1-9][0-9]*' -} - print_commit_range() { if [ -n "$1" ] && [ -n "$2" ]; then ahead="$(git rev-list --count "${1}..${2}" 2>/dev/null)" || ahead="0" @@ -166,7 +159,8 @@ element_local() { element_stash() { if [ -n "$opt_stash" ]; then - if cnt="$(git stash list | line_count)"; then + cnt="$(git rev-list --walk-reflogs --ignore-missing --count refs/stash)" + if [ "$cnt" -ne 0 ]; then printf '%s%b%b' "$cnt" "$STASH_ICON" "$COLOR_DEF" fi fi |
