Skip to content

Commit 4ce9085

Browse files
committed
fix: Repository::status() detects files added to the index in an unborn repository. (#1770)
Previously it wouldn't show them.
1 parent 90fef01 commit 4ce9085

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

gix/src/status/iter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ where
5353
crate::head::peel::to_object::Error::Unborn { .. },
5454
),
5555
),
56-
)) => None,
56+
)) => Some(gix_hash::ObjectId::empty_tree(self.repo.object_hash())),
5757
Err(err) => return Err(err.into()),
5858
},
5959
Some(Some(tree_id)) => Some(tree_id),
Binary file not shown.

gix/tests/fixtures/make_status_repos.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@ git init racy-git
3434
git init untracked-unborn
3535
(cd untracked-unborn
3636
touch untracked
37-
)
37+
)
38+
39+
git init untracked-added
40+
(cd untracked-added
41+
echo content >added
42+
git add added
43+
)

gix/tests/gix/status.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ mod into_iter {
113113
Ok(())
114114
}
115115

116+
#[test]
117+
fn untracked_added() -> crate::Result {
118+
let repo = repo("untracked-added")?;
119+
let mut status = repo.status(gix::progress::Discard)?.into_iter(None)?;
120+
let mut items: Vec<_> = status.by_ref().filter_map(Result::ok).collect();
121+
items.sort_by(|a, b| a.location().cmp(b.location()));
122+
insta::assert_debug_snapshot!(items, @r#""#);
123+
Ok(())
124+
}
125+
116126
#[test]
117127
fn error_during_tree_traversal_causes_failure() -> crate::Result {
118128
let repo = repo("untracked-only")?;

0 commit comments

Comments
 (0)