Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions gix/src/open/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,13 @@ impl ThreadSafeRepository {
section
.path
.as_deref()
.and_then(|p| gix_path::normalize(p.into(), current_dir))
.and_then(|p| {
if p.exists() {
gix_path::realpath_opts(p, current_dir, gix_path::realpath::MAX_SYMLINKS).ok()
} else {
gix_path::normalize(p.into(), current_dir).map(Cow::into_owned)
}
})
.is_some_and(|config_path| config_path.starts_with(git_dir))
}
let worktree_path = config
Expand Down Expand Up @@ -305,9 +311,14 @@ impl ThreadSafeRepository {
// the reason we use realpath instead of gix_path::normalize here is because there
// could be any intermediate symlinks (for example due to a symlinked .git
// directory)
worktree_dir = gix_path::realpath(&wt_path).ok();
// restore the relative path if possible after resolving the absolute path
if wt_path.is_relative() {
let is_relative = wt_path.is_relative();
worktree_dir = if wt_path.exists() {
gix_path::realpath(&wt_path).ok()
} else {
Some(wt_path.into_owned())
};
// restore the relative path if possible after resolving the absolute path
if is_relative {
if let Some(rel_path) = worktree_dir.as_deref().and_then(|p| p.strip_prefix(current_dir).ok()) {
worktree_dir = Some(rel_path.to_path_buf());
}
Expand Down
21 changes: 0 additions & 21 deletions gix/tests/gix/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,27 +310,6 @@ mod index_worktree {
);
}

#[test]
fn submodule_in_symlinked_dir() -> crate::Result {
use crate::util::named_subrepo_opts;
let repo = named_subrepo_opts(
"make_submodule_with_symlinked_git_dir.sh",
"symlinked-git-dir",
gix::open::Options::isolated(),
)?;
let status = repo
.status(gix::progress::Discard)?
.index_worktree_options_mut(|opts| {
opts.sorting =
Some(gix::status::plumbing::index_as_worktree_with_renames::Sorting::ByPathCaseSensitive);
})
.into_index_worktree_iter(None)?;
for change in status {
change?;
}
Ok(())
}

#[test]
fn submodule_modification() -> crate::Result {
let repo = submodule_repo("modified-untracked-and-submodule-head-changed-and-modified")?;
Expand Down