Skip to content

configurable gitbutler storage path via Git config#12646

Draft
Byron wants to merge 1 commit intogitbutlerapp:masterfrom
Byron:next3
Draft

configurable gitbutler storage path via Git config#12646
Byron wants to merge 1 commit intogitbutlerapp:masterfrom
Byron:next3

Conversation

@Byron
Copy link
Collaborator

@Byron Byron commented Mar 2, 2026

Fixes #11157 and resolves the issue of Nightly builds putting the database into the future, making it unreadable with the stable build.
As this new default for .git/gitbutler is configurable, the user can force both build types to

Tasks

  • review
  • test in the real
    • see how one would be able to 'revert' the behaviour by configuring the storage path for the nightly channel
  • protection for db clashes when configuration is setup globally (must get more unique DB name then)
  • validate CI
Codex Plan

Commit-Ready Plan: Configurable GitButler Storage Path with Channel Isolation

Summary

Change GitButler project storage to be resolved from Git config (gitbutler.storagePath) and default non-stable builds to channel-specific storage paths (.git/gitbutler.<channel>).
This addresses two motivations:

  1. Prevent channel interference from incompatible DB schemas/versions.
  2. Unblock repos on unsuitable drives (for example NFS/network mounts in #11157) by letting users point storage to a safe local path.

Scope and behavior

  1. Add a repository-local config key: gitbutler.storagePath.
  2. Resolution rules:
  3. If gitbutler.storagePath is absolute: use it directly.
  4. If gitbutler.storagePath is relative: resolve against repo.git_dir().
  5. If unset:
  6. Release builds default to <git_dir>/gitbutler.
  7. Non-release builds default to <git_dir>/gitbutler.<channel>.
  8. If channel is unavailable, treat as dev and use <git_dir>/gitbutler.dev.
  9. No automatic migration/fallback from legacy .git/gitbutler.
  10. Do not auto-write default path into .git/config.

Required implementation changes

  1. Introduce a shared resolver in but-core (RepositoryExt) so all callers use one implementation.
  2. Update but-ctx::Context to store the resolved project-data directory eagerly at creation time.
  3. Ensure all Context constructors create/open a real repository before finalizing context so full Git config is available.
  4. Route DB initialization in Context through the resolved project-data directory, not a hardcoded gitdir.join("gitbutler").
  5. Update legacy project management code (gitbutler-project add/get/delete storage dir operations) to use the same resolver logic.
  6. Update documentation/comments that currently imply only .git/gitbutler.

Public API / interface changes

  1. New recognized Git config key: gitbutler.storagePath.
  2. New RepositoryExt method for resolved storage path.
  3. Context::project_data_dir() becomes config-aware instead of hardcoded.
  4. Context and thread-safe context equivalents carry the resolved project-data directory as state.

Testing and acceptance criteria

  1. Resolver tests:
  2. Unset config + release => <git_dir>/gitbutler.
  3. Unset config + nightly => <git_dir>/gitbutler.nightly.
  4. Unset config + unknown non-release channel => <git_dir>/gitbutler.<channel>.
  5. Config absolute path respected exactly.
  6. Config relative path resolves against git_dir.
  7. Context tests:
  8. Creating context with configured path yields matching project_data_dir.
  9. DB path uses resolved directory.
  10. Thread-safe conversion preserves resolved directory.
  11. Legacy project controller tests:
  12. Add/get create the resolved storage directory.
  13. Delete removes the resolved storage directory.
  14. Non-regression:
  15. Existing stable default remains .git/gitbutler.
  16. No implicit migration/fallback behavior.

Rollout and compatibility notes

  1. Nightly/dev users with existing .git/gitbutler data will start isolated storage by default.
  2. Users affected by issue Database errors when loading repo from NFS Share #11157 can set gitbutler.storagePath to a local filesystem path suitable for SQLite.
  3. Release channel behavior remains unchanged unless override is configured.

Proposed commit message

Subject
ctx/project: make storage path git-configurable and channel-isolated

Body
Resolve GitButler project storage from gitbutler.storagePath and make non-release defaults channel-specific (.git/gitbutler.<channel>) to prevent channel interference from incompatible DB versions.

This also enables moving project storage off unsuitable repository drives (e.g. NFS/network mounts), addressing SQLite lock/rename failures reported in #11157.

Behavior notes: no automatic migration/fallback from legacy .git/gitbutler, and defaults are computed in-memory (not auto-persisted to git config).

Assumptions locked

  1. Config key is gitbutler.storagePath.
  2. Relative config paths are git_dir-relative.
  3. Isolation-only strategy for existing legacy directory.
  4. Legacy gitbutler-project storage directory operations are included in this same change.

@vercel
Copy link

vercel bot commented Mar 2, 2026

@Byron is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

Resolve GitButler project storage from Git config and make non-release defaults channel-specific (.git/gitbutler.<channel>) so app channels do not interfere with incompatible database versions.

Non-stable builds read gitbutler.<channel>.storagePath (for example gitbutler.nightly.storagePath), while release builds read gitbutler.storagePath. Relative paths are resolved against the repository git dir.

This also allows moving project storage off unsuitable repository drives (e.g. NFS/network mounts), addressing SQLite lock/rename failures reported in gitbutlerapp#11157.

Behavior notes: no automatic migration/fallback from legacy .git/gitbutler, defaults are computed in-memory (not auto-persisted to Git config), and path resolution now logs the effective storage path plus the config key to override it.

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
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.

Database errors when loading repo from NFS Share

1 participant