fix: support git worktrees in stack operations

Summary

  • Stack metadata storage used hardcoded .git/stacked/ paths which fails in git worktrees where .git is a file pointing to the actual git dir
  • Added GitDir() function using git rev-parse --git-dir to resolve the actual git directory at runtime
  • Updated all stack path resolution (StackLocation, AddStackRefDir, StackRootDir, GetStacks) to use it
  • Added worktree test cases and test helpers (InitGitWorktree, InitGitRepoOrWorktree)

Test plan

  • All existing stack tests pass
  • New worktree test variants pass for: AddStackRefDir, StackRootDir, AddStackRefFile, UpdateStackRefFile, GetStacks
  • Manual test: create a worktree, run glab stack create and glab stack save inside it
Edited by Daniel Bankmann

Merge request reports

Loading