pub struct WorktreeLock { /* private fields */ }Expand description
The held lock. Dropping it releases it; a panic or an early return therefore cannot leave the repository locked.
Implementations§
Source§impl WorktreeLock
impl WorktreeLock
Sourcepub fn path_for(git_common_dir: &Path) -> PathBuf
pub fn path_for(git_common_dir: &Path) -> PathBuf
The lock file for a repository, given its common git directory.
Sourcepub fn acquire(git_common_dir: &Path) -> Result<Self>
pub fn acquire(git_common_dir: &Path) -> Result<Self>
Take the lock, waiting up to WAIT for another holder to finish.
The primitive is O_CREAT|O_EXCL, which is atomic on every filesystem this runs on:
exactly one caller creates the file. A file older than STALE_AFTER is removed and
the attempt repeats, so a killed process is recovered from without a person being
asked to delete anything.
Sourcepub fn acquire_with(git_common_dir: &Path, wait: Duration) -> Result<Self>
pub fn acquire_with(git_common_dir: &Path, wait: Duration) -> Result<Self>
The same, with the waiting time as an argument, so a test does not wait twenty seconds to prove that a held lock is held.
Trait Implementations§
Source§impl Debug for WorktreeLock
impl Debug for WorktreeLock
Source§impl Drop for WorktreeLock
impl Drop for WorktreeLock
Auto Trait Implementations§
impl Freeze for WorktreeLock
impl RefUnwindSafe for WorktreeLock
impl Send for WorktreeLock
impl Sync for WorktreeLock
impl Unpin for WorktreeLock
impl UnsafeUnpin for WorktreeLock
impl UnwindSafe for WorktreeLock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more