Fix the status line git cost and its wrong optional-locks comment #1608

Closed
opened 2026-11-06 16:54:18 +00:00 by jared · 2 comments
Owner

Problem

~/.claude/statusline-command.sh runs three git processes on every render (rev-parse --git-dir, symbolic-ref --short HEAD or rev-parse --short HEAD, and status --porcelain). The comment at line 30 says it skips optional locks, but nothing sets GIT_OPTIONAL_LOCKS=0. A full status --porcelain runs on every render. This is row G-066 and open item Q-1 in docs/os-git/call-site-checklist.md. It does not depend on os-git.

Observed

statusline-command.sh:30 says "skip optional locks". Lines 31, 32, and 34 start the git processes. No line sets GIT_OPTIONAL_LOCKS.

Reproduce

grep -n "GIT_OPTIONAL_LOCKS" ~/.claude/statusline-command.sh

The command prints nothing.

Approach

Set GIT_OPTIONAL_LOCKS=0 on the git calls, so the status line never takes a lock that blocks the user's own git commands. Remove the false comment or make it true. Cut the process count where the same answer needs fewer calls (for example, read the branch and the dirty flag from one git status --porcelain=v2 --branch call). The file is outside the cc-os repository: edit it in place.

Required work: none beyond the acceptance criteria.

Acceptance criteria

  1. Given the script, when it is searched for GIT_OPTIONAL_LOCKS, then the git calls run with GIT_OPTIONAL_LOCKS=0.
  2. Given a repository, when the status line renders, then it shows the same branch name and dirty marker as before.
  3. Given a detached HEAD, when the status line renders, then it shows the short sha as before.
  4. Given a directory outside a repository, when the status line renders, then it starts no more than one git process.
  5. Given a render, when git processes are counted, then the count is lower than three for a clean repository.

Non-goals

Porting the script to Ruby or to os-git.

Origin

  • Trigger: User request in session 1a5b2630-09c9-46cb-aee4-a5a98e2e7d24 on 2026-11-06: one os-git gem for all local git work in cc-os and the user's projects.
  • Improvised this session: none
  • Chain: status line slow and comment wrong ← no GIT_OPTIONAL_LOCKS and three git calls per render ← DESIGN (~/.claude/statusline-command.sh)
  • Root candidate: none found; searched open issues for git, worktree, octokit, ruby port, python, statusline, reset --hard. Related but not a match: #845, #853, #857, #1527, #1554.
  • Where: ~/.claude/statusline-command.sh
  • Session: 1a5b2630-09c9-46cb-aee4-a5a98e2e7d24
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/1a5b2630-09c9-46cb-aee4-a5a98e2e7d24.jsonl
## Problem `~/.claude/statusline-command.sh` runs three git processes on every render (`rev-parse --git-dir`, `symbolic-ref --short HEAD` or `rev-parse --short HEAD`, and `status --porcelain`). The comment at line 30 says it skips optional locks, but nothing sets `GIT_OPTIONAL_LOCKS=0`. A full `status --porcelain` runs on every render. This is row G-066 and open item Q-1 in `docs/os-git/call-site-checklist.md`. It does not depend on `os-git`. ## Observed `statusline-command.sh:30` says "skip optional locks". Lines 31, 32, and 34 start the git processes. No line sets `GIT_OPTIONAL_LOCKS`. ## Reproduce ``` grep -n "GIT_OPTIONAL_LOCKS" ~/.claude/statusline-command.sh ``` The command prints nothing. ## Approach Set `GIT_OPTIONAL_LOCKS=0` on the git calls, so the status line never takes a lock that blocks the user's own git commands. Remove the false comment or make it true. Cut the process count where the same answer needs fewer calls (for example, read the branch and the dirty flag from one `git status --porcelain=v2 --branch` call). The file is outside the cc-os repository: edit it in place. Required work: none beyond the acceptance criteria. ## Acceptance criteria 1. Given the script, when it is searched for `GIT_OPTIONAL_LOCKS`, then the git calls run with `GIT_OPTIONAL_LOCKS=0`. 2. Given a repository, when the status line renders, then it shows the same branch name and dirty marker as before. 3. Given a detached HEAD, when the status line renders, then it shows the short sha as before. 4. Given a directory outside a repository, when the status line renders, then it starts no more than one git process. 5. Given a render, when git processes are counted, then the count is lower than three for a clean repository. ## Non-goals Porting the script to Ruby or to `os-git`. ## Origin - Trigger: User request in session 1a5b2630-09c9-46cb-aee4-a5a98e2e7d24 on 2026-11-06: one os-git gem for all local git work in cc-os and the user's projects. - Improvised this session: none - Chain: status line slow and comment wrong ← no GIT_OPTIONAL_LOCKS and three git calls per render ← DESIGN (~/.claude/statusline-command.sh) - Root candidate: none found; searched open issues for git, worktree, octokit, ruby port, python, statusline, reset --hard. Related but not a match: #845, #853, #857, #1527, #1554. - Where: ~/.claude/statusline-command.sh - Session: 1a5b2630-09c9-46cb-aee4-a5a98e2e7d24 - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/1a5b2630-09c9-46cb-aee4-a5a98e2e7d24.jsonl
Author
Owner

Work started by the #1610 orchestrator, session 5b14a4ef-91b2-45c0-a729-baa17682a39a. Branch: ticket-1608.

Work started by the #1610 orchestrator, session 5b14a4ef-91b2-45c0-a729-baa17682a39a. Branch: ticket-1608.
Author
Owner

Resolution

Done: statusline-command.sh runs one GIT_OPTIONAL_LOCKS=0 git status --porcelain=v2 --branch call per render; false comment removed; G-066 and Q-1 marked.

Evidence: PATH-shim process counts: clean 3 to 1, dirty 3 to 1, detached 4 to 1, unborn 3 to 1, non-repo 1 to 1. Old and new output byte-identical in seven scenarios. Checklist commit f725c77f.

Follow-ups: none (detached sha is now fixed at 7 characters; accepted as cosmetic)

## Resolution **Done:** statusline-command.sh runs one GIT_OPTIONAL_LOCKS=0 git status --porcelain=v2 --branch call per render; false comment removed; G-066 and Q-1 marked. **Evidence:** PATH-shim process counts: clean 3 to 1, dirty 3 to 1, detached 4 to 1, unborn 3 to 1, non-repo 1 to 1. Old and new output byte-identical in seven scenarios. Checklist commit f725c77f. **Follow-ups:** none (detached sha is now fixed at 7 characters; accepted as cosmetic)
jared closed this issue 2026-11-06 17:15:18 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#1608
No description provided.