Skip to content

Commit

Permalink
fix: Repository::status() detects files added to the index in an un…
Browse files Browse the repository at this point in the history
…born repository. (#1770)

Previously it wouldn't show them.
  • Loading branch information
Byron committed Jan 16, 2025
1 parent 90fef01 commit 4ce9085
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gix/src/status/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ where
crate::head::peel::to_object::Error::Unborn { .. },
),
),
)) => None,
)) => Some(gix_hash::ObjectId::empty_tree(self.repo.object_hash())),
Err(err) => return Err(err.into()),
},
Some(Some(tree_id)) => Some(tree_id),
Expand Down
Binary file modified gix/tests/fixtures/generated-archives/make_status_repos.tar
Binary file not shown.
8 changes: 7 additions & 1 deletion gix/tests/fixtures/make_status_repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ git init racy-git
git init untracked-unborn
(cd untracked-unborn
touch untracked
)
)

git init untracked-added
(cd untracked-added
echo content >added
git add added
)
10 changes: 10 additions & 0 deletions gix/tests/gix/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ mod into_iter {
Ok(())
}

#[test]
fn untracked_added() -> crate::Result {
let repo = repo("untracked-added")?;
let mut status = repo.status(gix::progress::Discard)?.into_iter(None)?;
let mut items: Vec<_> = status.by_ref().filter_map(Result::ok).collect();
items.sort_by(|a, b| a.location().cmp(b.location()));
insta::assert_debug_snapshot!(items, @r#""#);
Ok(())
}

#[test]
fn error_during_tree_traversal_causes_failure() -> crate::Result {
let repo = repo("untracked-only")?;
Expand Down

0 comments on commit 4ce9085

Please sign in to comment.