@@ -35,6 +35,9 @@ internal StashCollection(Repository repo)
35
35
36
36
/// <summary>
37
37
/// Returns an enumerator that iterates through the collection.
38
+ /// <para>
39
+ /// The enumerator returns the stashes by descending order (last stash is returned first).
40
+ /// </para>
38
41
/// </summary>
39
42
/// <returns>An <see cref = "IEnumerator{T}" /> object that can be used to iterate through the collection.</returns>
40
43
public IEnumerator < Stash > GetEnumerator ( )
@@ -78,21 +81,36 @@ public virtual Stash Add(Signature stasher, string message = null, StashOptions
78
81
return new Stash ( repo , oid , 0 ) ;
79
82
}
80
83
84
+ /// <summary>
85
+ /// Remove a single stashed state from the stash list.
86
+ /// </summary>
87
+ /// <param name = "index">The index of the stash to remove (0 being the most recent one).</param>
88
+ public virtual void Remove ( int index )
89
+ {
90
+ if ( index < 0 )
91
+ {
92
+ throw new ArgumentException ( "The passed index must be a positive integer." , "index" ) ;
93
+ }
94
+
95
+ Proxy . git_stash_drop ( repo . Handle , index ) ;
96
+ }
97
+
81
98
/// <summary>
82
99
/// Remove a single stashed state from the stash list.
83
100
/// </summary>
84
101
/// <param name = "stashRefLog">The log reference of the stash to delete. Pattern is "stash@{i}" where i is the index of the stash to remove</param>
102
+ [ Obsolete ( "This method will be removed in the next release. Please use Repository.Stashes.Remove(int) instead." ) ]
85
103
public virtual void Remove ( string stashRefLog )
86
104
{
87
105
Ensure . ArgumentNotNullOrEmptyString ( stashRefLog , "stashRefLog" ) ;
88
106
89
107
int index ;
90
- if ( ! TryExtractStashIndexFromRefLog ( stashRefLog , out index ) || index < 0 )
108
+ if ( ! TryExtractStashIndexFromRefLog ( stashRefLog , out index ) || index < 0 )
91
109
{
92
110
throw new ArgumentException ( "must be a valid stash log reference. Pattern is 'stash@{i}' where 'i' is an integer" , "stashRefLog" ) ;
93
111
}
94
112
95
- Proxy . git_stash_drop ( repo . Handle , index ) ;
113
+ Remove ( index ) ;
96
114
}
97
115
98
116
private static bool TryExtractStashIndexFromRefLog ( string stashRefLog , out int index )
0 commit comments