Skip to content

fix: resolve --file paths from repository subdirectories#2926

Open
leno23 wants to merge 1 commit into
gitui-org:masterfrom
leno23:fix/file-flag-subdir-2871
Open

fix: resolve --file paths from repository subdirectories#2926
leno23 wants to merge 1 commit into
gitui-org:masterfrom
leno23:fix/file-flag-subdir-2871

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

  • Fixes --file / -f when gitui is launched from a subdirectory of the repository (e.g. cd frontend && gitui --file src/index.html).
  • Previously the path was made relative to the git directory (.git), which breaks in linked worktrees and non-root cwd; it now resolves against the repository workdir and the current working directory.

Test plan

  • cargo test resolve_select_file (unit tests for cwd in repo root and in a subdirectory)
  • Manual: gitui --file frontend/src/index.html from repo root
  • Manual: cd frontend && gitui --file src/index.html

Fixes #2871

Made with Cursor

Strip the repository workdir instead of the git directory when
converting --file to a repo-relative path so launching gitui from a
subdirectory selects the intended file in the Files tab.

Fixes gitui-org#2871

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.

Flag --file not working on sub directories

1 participant