fix(stacks): share stacks across worktrees

Description

Currently, StackLocation() uses git rev-parse --git-dir, which in a linked worktree points to the per-worktree admin directory (.git/worktrees/<name>). This causes each worktree to have isolated stack metadata, so stacks created in one worktree are invisible from another.

This MR changes stack metadata storage to use git rev-parse --git-common-dir (the shared repository directory), so all worktrees for the same repo see the same stacks going forward.

Migration path for users

This MR does not automatically migrate legacy per-worktree stack metadata. The stack commands are experimental and worktree support is recent, so this fixes the bug on a go-forward basis. If you used stacks inside a worktree on an older glab, manually move .git/worktrees/<name>/stacked/* into .git/stacked/.

Resolves #8355 (closed)

How has this been tested?

  • Added tests covering the new changes and ran them
  • Installed the cli and tested the new behavior

Screenshots (if appropriate):

Edited by Ahmed Abdelbaset

Merge request reports

Loading