From a3eae1ed124cbce761d7ba69628ca8296101ca69 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 22 Jan 2023 08:44:26 -0800 Subject: [PATCH] Add docs about Repository::index ownership. --- src/repo.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/repo.rs b/src/repo.rs index a2f3745555..2febfffe93 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -1012,6 +1012,11 @@ impl Repository { /// /// If a custom index has not been set, the default index for the repository /// will be returned (the one located in .git/index). + /// + /// **Caution**: If the [`Repository`] of this index is dropped, then this + /// [`Index`] will become detached, and most methods on it will fail. See + /// [`Index::open`]. Be sure the repository has a binding such as a local + /// variable to keep it alive at least as long as the index. pub fn index(&self) -> Result { let mut raw = ptr::null_mut(); unsafe {