Skip to content

Commit 72134f5

Browse files
CopilotByron
andcommitted
fix: ignore assume-unchanged submodule path replaced by symlink in status
Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
1 parent f7277f3 commit 72134f5

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

gix-dir/src/walk/classify.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,23 @@ fn resolve_file_type_with_index(
372372
None
373373
};
374374
(
375-
kind.filter(|_| entry.flags.contains(gix_index::entry::Flags::UPTODATE)),
375+
kind.filter(|_| {
376+
entry
377+
.flags
378+
.intersects(gix_index::entry::Flags::UPTODATE | gix_index::entry::Flags::ASSUME_VALID)
379+
}),
376380
kind,
377381
)
378382
}
379383

380384
fn icase_directory_to_kinds(dir: Option<&gix_index::Entry>) -> (Option<entry::Kind>, Option<entry::Kind>) {
381385
let index_kind = dir.map(|_| entry::Kind::Directory);
382386
let uptodate_kind = dir
383-
.filter(|entry| entry.flags.contains(gix_index::entry::Flags::UPTODATE))
387+
.filter(|entry| {
388+
entry
389+
.flags
390+
.intersects(gix_index::entry::Flags::UPTODATE | gix_index::entry::Flags::ASSUME_VALID)
391+
})
384392
.map(|_| entry::Kind::Directory);
385393
(uptodate_kind, index_kind)
386394
}

gix/tests/fixtures/make_status_repos.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,19 @@ git init symlink-replaces-tracked-dir
5353
rm -rf tracked
5454
ln -s target tracked
5555
)
56+
57+
git init -q module
58+
(cd module
59+
touch this
60+
git add this
61+
git commit -q -m c1
62+
)
63+
64+
git init -q submodule-assume-unchanged-symlink
65+
(cd submodule-assume-unchanged-symlink
66+
git submodule add ../module sub
67+
git commit -q -m "add submodule"
68+
git update-index --assume-unchanged sub
69+
rm -Rf sub
70+
ln -s ../module sub
71+
)

gix/tests/gix/status.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,15 @@ mod into_iter {
265265
Ok(())
266266
}
267267

268+
#[test]
269+
fn submodule_assume_unchanged_replaced_with_symlink_is_ignored() -> crate::Result {
270+
let repo = repo("submodule-assume-unchanged-symlink")?;
271+
let mut status = repo.status(gix::progress::Discard)?.into_iter(None)?;
272+
let items: Vec<_> = status.by_ref().filter_map(Result::ok).collect();
273+
assert!(items.is_empty(), "assume-unchanged submodule should not show up in status");
274+
Ok(())
275+
}
276+
268277
#[test]
269278
fn error_during_tree_traversal_causes_failure() -> crate::Result {
270279
let repo = repo("untracked-only")?;

0 commit comments

Comments
 (0)