11using LibGit2Sharp . Core ;
2+ using LibGit2Sharp . Core . Handles ;
23using System ;
34using System . Collections . Generic ;
45using System . Diagnostics ;
@@ -16,19 +17,21 @@ public class Worktree : IEquatable<Worktree>, IBelongToARepository
1617 private static readonly LambdaEqualityHelper < Worktree > equalityHelper =
1718 new LambdaEqualityHelper < Worktree > ( x => x . Name ) ;
1819
20+ private readonly WorktreeHandle handle ;
1921 private readonly Repository parent ;
2022 private readonly Repository worktree ;
2123 private readonly string name ;
22- private readonly WorktreeLock worktreeLock ;
24+ private WorktreeLock worktreeLock ;
2325
2426 /// <summary>
2527 /// Needed for mocking purposes.
2628 /// </summary>
2729 protected Worktree ( )
2830 { }
2931
30- internal Worktree ( Repository repo , string name , Repository worktree , WorktreeLock worktreeLock )
32+ internal Worktree ( WorktreeHandle handle , Repository repo , string name , Repository worktree , WorktreeLock worktreeLock )
3133 {
34+ this . handle = Proxy . git_worktree_lookup ( repo . Handle , name ) ;
3235 this . parent = repo ;
3336 this . name = name ;
3437 this . worktree = worktree ;
@@ -75,6 +78,24 @@ public bool Equals(Worktree other)
7578 return equalityHelper . Equals ( this , other ) ;
7679 }
7780
81+ /// <summary>
82+ /// Unlock the worktree
83+ /// </summary>
84+ public void Unlock ( )
85+ {
86+ Proxy . git_worktree_unlock ( handle ) ;
87+ this . worktreeLock = Proxy . git_worktree_is_locked ( handle ) ;
88+ }
89+
90+ /// <summary>
91+ /// Lock the worktree
92+ /// </summary>
93+ public void Lock ( string reason )
94+ {
95+ Proxy . git_worktree_lock ( handle , reason ) ;
96+ this . worktreeLock = Proxy . git_worktree_is_locked ( handle ) ;
97+ }
98+
7899 /// <summary>
79100 /// Returns the hash code for this instance.
80101 /// </summary>
0 commit comments