repo: Add two more cap-std APIs

Followup to the previous PR.  I realized now with `io_lifetimes`
we can offer a safe `dfd_borrow()` that *borrows* the file descriptor
for the repository.  (In contrast to the current `.dfd()` that returns
the raw version)

Building on that, add another API that re-acquires a `Dir` instance.
(In the future in theory we could optimize this more by knowing
 whether or not the repo was constructed via cap-std, and perhaps
 in theory synthesize a `&Dir` reference, but I don't think we
 need that now)
This commit is contained in:
Colin Walters committed 2022-05-06 12:53:57 -04:00
1 parent 6940896c4e
commit 19224a411a
2 files changed
+16

No files matched your search

+4
View File
@@ -31,6 +31,10 @@ fn should_commit_content_to_repo_and_list_refs_again() {
fn cap_std_commit() {
let test_repo = CapTestRepo::new();
assert!(test_repo.dir.exists("config"));
// Also test re-acquiring a new dfd
assert!(test_repo.repo.dfd_as_dir().unwrap().exists("config"));
assert!(test_repo.repo.require_rev("nosuchrev").is_err());
let mtree = create_mtree(&test_repo.repo);