Skip to content

Comments

feat: support delete operation in bare repositories#150

Merged
k1LoW merged 1 commit intok1LoW:mainfrom
usadamasa:support-delete-in-bare
Feb 19, 2026
Merged

feat: support delete operation in bare repositories#150
k1LoW merged 1 commit intok1LoW:mainfrom
usadamasa:support-delete-in-bare

Conversation

@usadamasa
Copy link
Contributor

@usadamasa usadamasa commented Feb 19, 2026

Summary

#130 (Phase 3: delete operation)

This is the final phase of #130. With this PR, all bare repository operations are now supported:

Changes

  • Enable git wt -d <branch> and git wt -D <branch> in bare repositories and worktrees created from bare repos
  • Remove AssertNotBareRepository() guard for delete operations
  • Add IsBareEntry() to detect and protect the bare repository root entry from deletion
  • Add HeadBranch() to resolve the branch HEAD points to (used for bare entry detection by branch name)
  • Protect bare entry from deletion via both branch name (git wt -d main) and path (git wt -d .)
  • Remove "bare repositories not supported" notes from README and CLI help (all operations now supported)
  • Extract shared test helpers (createBareWorktree, commitUnmergedChange, assertLastLine) for bare delete tests

Behavior

Delete from bare root

$ cd /tmp/repo.git
$ git wt feature          # create worktree
$ git wt -d feature       # safe delete: works
$ git wt -d main          # delete bare entry: error
cannot delete bare repository entry "main": the bare repository root cannot be removed as a worktree

Delete from bare-derived worktree

$ cd /tmp/.wt/feature
$ git wt -d other-branch  # delete another worktree: works
$ git wt -D feature       # delete current worktree: works (cd back to bare root via shell integration)

Delete bare entry via path

$ cd /tmp/repo.git
$ git wt -d .             # error: bare entry protected
cannot delete bare repository entry ".": the bare repository root cannot be removed as a worktree

Test plan

  • E2E: safe delete of linked worktree from bare root
  • E2E: force delete of worktree with unmerged commits from bare root
  • E2E: deleting bare entry by branch name returns error
  • E2E: deleting bare entry by path (.) returns error
  • E2E: delete other worktree from bare-derived worktree
  • E2E: delete current worktree from inside (shell integration cd to bare root)
  • E2E: delete last worktree, cd back to bare root
  • E2E: safe delete fails with modified files, suggests -D
  • E2E: dotgit bare variant (core.bare=true) delete works

🤖 Generated with Claude Code

@usadamasa usadamasa force-pushed the support-delete-in-bare branch 2 times, most recently from 8d900a1 to 2776bca Compare February 19, 2026 12:33
@usadamasa usadamasa force-pushed the support-delete-in-bare branch from 2776bca to b00d8ba Compare February 19, 2026 12:37
@usadamasa usadamasa marked this pull request as ready for review February 19, 2026 12:39
@k1LoW k1LoW added enhancement New feature or request tagpr:minor labels Feb 19, 2026
@k1LoW
Copy link
Owner

k1LoW commented Feb 19, 2026

@usadamasa GREAT WORK!!!!!
Thank you for completing all three phases of bare repository support!

@k1LoW k1LoW merged commit fb76d52 into k1LoW:main Feb 19, 2026
3 checks passed
@github-actions github-actions bot mentioned this pull request Feb 19, 2026
@usadamasa usadamasa deleted the support-delete-in-bare branch February 20, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tagpr:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants