Skip to content

Worktree path does not expand #4708

@iLynxcat

Description

@iLynxcat

Describe the bug
When creating a new worktree and entering its path (i.e. ~/path/to/worktree or ../worktree-name), those path segments (~, ..) do not expand because they are normally expanded automatically by the terminal (afaik) and instead a directory at /path/to/repository/~/path/to/worktree is created.

To Reproduce
Steps to reproduce the behavior:

  1. Open a repository by running "lazygit" when pwd is a git repository
  2. Activate Worktrees tab by typing 2 then ]
  3. Choose "New worktree" by typing n
  4. Choose "Create worktree from ref"
  5. Choose a base ref (I recommend using your current checked out ref)
  6. Enter a worktree path that begins with ".." or "~", and submit
  7. Enter a new branch name (I recommend test/worktree-creation)
  8. Take note of the new Worktree -> Path relative to the Worktree -> Path when using the arrow key select your previous checked-out worktree

Expected behavior
A clear and concise description of what you expected to happen.

I expect ".." and "~" to expand as they would if I ran the command in my terminal directly, and the worktree to be created accordingly

Screenshots
If applicable, add screenshots to help explain your problem.

A worktree existing at path /Users/lynx/Developer/OBFUSCATED_PATH/~/path/to/worktree Finder window navigated to a project directory, with a subdirectory '~' followed by path/to/worktree, containing the worktree files directly.

Version info:
Run lazygit --version and paste the result here
commit=, build date=, build source=Homebrew, version=0.53.0, os=darwin, arch=arm64, git version=2.39.5 (Apple Git-154)
Run git --version and paste the result here
git version 2.39.5 (Apple Git-154)

Additional context
Add any other context about the problem here.

None to share

Note: please try updating to the latest version or manually building the latest master to see if the issue still occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions