Skip to content

fix: sandbox-friendly git tests and linked-gitdir support - #79

Open
simtel12 wants to merge 1 commit into
hokwangchoi:masterfrom
simtel12:pgit/gregorios-leach/fix--sandbox-friendly-git-tests-and-linked-gitdir
Open

fix: sandbox-friendly git tests and linked-gitdir support#79
simtel12 wants to merge 1 commit into
hokwangchoi:masterfrom
simtel12:pgit/gregorios-leach/fix--sandbox-friendly-git-tests-and-linked-gitdir

Conversation

@simtel12

@simtel12 simtel12 commented May 6, 2026

Copy link
Copy Markdown

Summary

Some environments (including constrained sandboxes) block writes under a worktree’s .git directory while still allowing a sibling git directory. Repositories created with git init --separate-git-dir also keep metadata outside <worktree>/.git. This pull request resolves the real Git directory via git rev-parse, uses it for rebase detection and pgit-sync-state.json, and updates integration tests to use separate git dirs under target/ with an optional PGIT_TEST_TMP override.

Changes

  • Repo::git_directory(): Resolves the absolute git directory using git rev-parse --absolute-git-dir, with fallback to --git-dir and path normalization relative to the worktree when Git returns a relative path.
  • Rebase and sync state: is_rebase_in_progress, read_sync_state, and write_sync_state read and write under the resolved git directory instead of assuming .git/ lives directly inside the worktree.
  • Integration tests (tests/test_git_ops.rs): Ephemeral repos use git init --separate-git-dir; scratch roots default to target/pgit-integration-tmp/ (override with PGIT_TEST_TMP); commit/tag GPG signing is disabled in-repo so tests do not depend on ~/.gnupg; teardown removes both the worktree and the companion git directory.
  • AGENTS.md: Documents the usual cargo build, cargo test, Clippy, and rustfmt --check workflow for contributors.

Test plan

  • cargo test (library unit tests and test_git_ops integration tests)

- Integration tests use git init --separate-git-dir, scratch under target/,
  local gpgsign disabled, and cleanup of sibling .git dir.
- Resolve real git directory via rev-parse for rebase detection and
  pgit-sync-state when using separate git directories.

Add AGENTS.md with build, test, and clippy/fmt commands.

Co-authored-by: Cursor <cursoragent@cursor.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.

3 participants