Skip to content

feat(cli): add a git-bug cache rebuild command - #1633

Open
davicbtoliveira wants to merge 3 commits into
git-bug:trunkfrom
davicbtoliveira:feat/cache-rebuild
Open

davicbtoliveira wants to merge 3 commits into
git-bug:trunkfrom
davicbtoliveira:feat/cache-rebuild

Conversation

@davicbtoliveira

@davicbtoliveira davicbtoliveira commented Sep 26, 2026 •

Copy link
Copy Markdown

Refs #1420

The cache doesn't notice changes made to refs/bugs/* and refs/identities/* by other tools (plain git fetch/push, git bundle restore, git update-ref -d), so git-bug keeps showing deleted bugs and misses fetched ones until .git/git-bug/cache is removed by hand (see discussion #1332 and #1583).

This adds a supported way to do that:

$ git bug cache rebuild
Building cache...

Changes

  • cache: NewRepoCacheRebuild takes the repository lock, drops the cache on disk and rebuilds excerpts and indexes from the git data. It refuses, without touching anything, if another process holds the lock. It only reads refs and never modifies git data or config.
  • cache: when a build fails, every excerpt file is removed (sub-caches build concurrently and used to leave the successful ones on disk), so the next open rebuilds instead of loading a partial cache.
  • commands: new cache command with a rebuild subcommand, following the noun/action pattern of doc/design/cli-convention.md.
  • commands: cache and wipe are grouped under a new "Maintenance" help group. This is my take on the "root namespace for admin things" suggested in add new command to refresh the cache #1420: grouping in the help output without changing the path of wipe. Happy to adjust the naming if you prefer something else (e.g. reset <target>).
  • Regenerated md/man docs.

Out of scope

Tests

go test ./cache/... ./commands/.... New tests cover refs removed, restored or moved outside git-bug; rebuild refused while the repo is locked; a failed rebuild leaving no excerpts and the next open rebuilding; argument validation; and the help grouping.

davicbtoliveira and others added 3 commits September 26, 2026 00:20
NewRepoCacheRebuild takes the repository lock, drops the cache on disk
and rebuilds it from the git data, so that changes made to git-bug's
references by other tools are picked up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds a `cache` command with a `rebuild` subcommand, and groups `cache`
and `wipe` under a new "Maintenance" help group.

Refs git-bug#1420

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sub-caches build concurrently and each writes its excerpts as soon as it
succeeds, so a failure in one left the others on disk. Remove them all,
so a failed build leaves nothing to load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@MichaelMure MichaelMure changed the title feat(cli): add git-bug cache rebuild feat(cli): add a git-bug cache rebuild command Sep 26, 2026
@MichaelMure

Copy link
Copy Markdown
Contributor

I appreciate the help, but this is unlikely to be merged. I'm working at the moment on making the cache detect/repair a mismatch with the data on disk (for a lot of reasons), which should make that need of exposing this to the user obsolete.

I'll keep the PR around for now, in the case where there is still some need after I'm done.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants