Skip to content

Commit 222532a

Browse files
use new fixture.sh + ignore the generated archive
1 parent e1d9ae3 commit 222532a

File tree

5 files changed

+39
-21
lines changed

5 files changed

+39
-21
lines changed

gix/src/open/repository.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,8 @@ impl ThreadSafeRepository {
308308
worktree_dir = gix_path::realpath(&wt_path).ok();
309309
// restore the relative path if possible after resolving the absolute path
310310
if wt_path.is_relative() {
311-
if let Ok(cwd) = std::env::current_dir() {
312-
if let Some(rel_path) = worktree_dir.as_deref().and_then(|p| p.strip_prefix(&cwd).ok()) {
313-
worktree_dir = Some(rel_path.to_path_buf());
314-
}
311+
if let Some(rel_path) = worktree_dir.as_deref().and_then(|p| p.strip_prefix(&current_dir).ok()) {
312+
worktree_dir = Some(rel_path.to_path_buf());
315313
}
316314
}
317315

gix/tests/fixtures/generated-archives/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
/make_signatures_repo.tar
99
/make_diff_repos.tar
1010
/make_submodule_with_worktree.tar
11-
/repo_with_untracked_files.tar
11+
/repo_with_untracked_files.tar
12+
/make_submodule_with_symlinked_git_dir.tar
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
git init -q module1
5+
(cd module1
6+
touch this
7+
mkdir subdir
8+
touch subdir/that
9+
git add .
10+
git commit -q -m c1
11+
echo hello >> this
12+
git commit -q -am c2
13+
touch untracked
14+
)
15+
16+
mkdir symlinked-git-dir
17+
(cd symlinked-git-dir
18+
git init -q r1
19+
(cd r1
20+
git commit -q --allow-empty -m "init"
21+
)
22+
23+
git config -f r1/.git/config core.worktree "$(pwd)"
24+
ln -s r1/.git .git
25+
26+
git -c protocol.file.allow=always submodule add ../module1 m1
27+
git commit -m "add module 1"
28+
)

gix/tests/fixtures/make_submodules.sh

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,4 @@ git clone with-submodules not-a-submodule
151151
git add m1 && git commit -m "no submodule in index and commit, but in configuration"
152152
)
153153

154-
git init unborn
155-
156-
mkdir symlinked-git-dir
157-
(cd symlinked-git-dir
158-
git init -q r1
159-
(cd r1
160-
git commit -q --allow-empty -m "init"
161-
)
162-
163-
git config -f r1/.git/config core.worktree "$(pwd)"
164-
ln -s r1/.git .git
165-
166-
git -c protocol.file.allow=always submodule add ../module1 m1
167-
git commit -m "add module 1"
168-
)
154+
git init unborn

gix/tests/gix/status.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,12 @@ mod index_worktree {
312312

313313
#[test]
314314
fn submodule_in_symlinked_dir() -> crate::Result {
315-
let repo = submodule_repo("symlinked-git-dir")?;
315+
use crate::util::named_subrepo_opts;
316+
let repo = named_subrepo_opts(
317+
"make_submodule_with_symlinked_git_dir.sh",
318+
"symlinked-git-dir",
319+
gix::open::Options::isolated(),
320+
)?;
316321
let status = repo
317322
.status(gix::progress::Discard)?
318323
.index_worktree_options_mut(|opts| {

0 commit comments

Comments
 (0)