Skip to content

Commit 0d8cd1e

Browse files
fix: worktree incorrect when .git is symlink (#2052)
1 parent 2946c2b commit 0d8cd1e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gix/src/open/repository.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ impl ThreadSafeRepository {
301301
| gix_config::Source::EnvOverride => wt_path,
302302
_ => git_dir.join(wt_path).into(),
303303
};
304-
worktree_dir = gix_path::normalize(wt_path, current_dir).map(Cow::into_owned);
304+
// the reason we use realpath instead of gix_path::normalize here is because there
305+
// could be any intermediate symlinks (for example due to a symlinked .git
306+
// directory)
307+
worktree_dir = gix_path::realpath(wt_path).ok();
305308
#[allow(unused_variables)]
306309
if let Some(worktree_path) = worktree_dir.as_deref().filter(|wtd| !wtd.is_dir()) {
307310
gix_trace::warn!("The configured worktree path '{}' is not a directory or doesn't exist - `core.worktree` may be misleading", worktree_path.display());

0 commit comments

Comments
 (0)