Skip to content

Commit 59bb979

Browse files
authored
Merge pull request #922 from ehuss/repo-index-life
Add docs about Repository::index ownership.
2 parents 1ab62f3 + a3eae1e commit 59bb979

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/repo.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,11 @@ impl Repository {
10121012
///
10131013
/// If a custom index has not been set, the default index for the repository
10141014
/// will be returned (the one located in .git/index).
1015+
///
1016+
/// **Caution**: If the [`Repository`] of this index is dropped, then this
1017+
/// [`Index`] will become detached, and most methods on it will fail. See
1018+
/// [`Index::open`]. Be sure the repository has a binding such as a local
1019+
/// variable to keep it alive at least as long as the index.
10151020
pub fn index(&self) -> Result<Index, Error> {
10161021
let mut raw = ptr::null_mut();
10171022
unsafe {

0 commit comments

Comments
 (0)