File tree Expand file tree Collapse file tree 4 files changed +14
-44
lines changed Expand file tree Collapse file tree 4 files changed +14
-44
lines changed Original file line number Diff line number Diff line change @@ -107,27 +107,6 @@ public void CanEnumerateRepositorySubmodules()
107
107
}
108
108
}
109
109
110
- [ Theory ]
111
- [ InlineData ( "sm_changed_head" ) ]
112
- [ InlineData ( "sm_changed_head/" ) ]
113
- public void CanStageChangeInSubmoduleViaSubmoduleStage ( string submodulePath )
114
- {
115
- var path = BuildTemporarySubmoduleClone ( ) ;
116
-
117
- using ( var repo = new Repository ( path ) )
118
- {
119
- var submodule = repo . Submodules [ submodulePath ] ;
120
-
121
- var statusBefore = submodule . RetrieveStatus ( ) ;
122
- Assert . Equal ( SubmoduleStatus . WorkDirModified , statusBefore & SubmoduleStatus . WorkDirModified ) ;
123
-
124
- submodule . Stage ( ) ;
125
-
126
- var statusAfter = submodule . RetrieveStatus ( ) ;
127
- Assert . Equal ( SubmoduleStatus . IndexModified , statusAfter & SubmoduleStatus . IndexModified ) ;
128
- }
129
- }
130
-
131
110
[ Theory ]
132
111
[ InlineData ( "sm_changed_head" ) ]
133
112
// [InlineData("sm_changed_head/")] // AmbiguousSpecificationException - Do we want to support this?
Original file line number Diff line number Diff line change @@ -170,17 +170,9 @@ public virtual void Stage(IEnumerable<string> paths)
170
170
{
171
171
RemoveFromIndex ( relativePath ) ;
172
172
}
173
- else
173
+ else if ( ! repo . Submodules . TryStage ( relativePath , true ) )
174
174
{
175
- var submodule = repo . Submodules [ relativePath ] ;
176
- if ( submodule != null )
177
- {
178
- submodule . Stage ( ) ;
179
- }
180
- else
181
- {
182
- AddToIndex ( relativePath ) ;
183
- }
175
+ AddToIndex ( relativePath ) ;
184
176
}
185
177
}
186
178
Original file line number Diff line number Diff line change @@ -94,19 +94,6 @@ public virtual SubmoduleUpdate UpdateRule
94
94
get { return Proxy . git_submodule_update ( handle ) ; }
95
95
}
96
96
97
- /// <summary>
98
- /// Add current submodule HEAD commit to index of superproject.
99
- /// </summary>
100
- public virtual void Stage ( )
101
- {
102
- Stage ( true ) ;
103
- }
104
-
105
- internal virtual void Stage ( bool writeIndex )
106
- {
107
- Proxy . git_submodule_add_to_index ( handle , writeIndex ) ;
108
- }
109
-
110
97
/// <summary>
111
98
/// Retrieves the state of this submodule in the working directory compared to the staging area and the latest commmit.
112
99
/// </summary>
Original file line number Diff line number Diff line change @@ -63,6 +63,18 @@ IEnumerator IEnumerable.GetEnumerator()
63
63
return GetEnumerator ( ) ;
64
64
}
65
65
66
+ internal bool TryStage ( string relativePath , bool writeIndex )
67
+ {
68
+ using ( var handle = Proxy . git_submodule_lookup ( repo . Handle , relativePath ) )
69
+ {
70
+ if ( handle == null )
71
+ return false ;
72
+
73
+ Proxy . git_submodule_add_to_index ( handle , writeIndex ) ;
74
+ return true ;
75
+ }
76
+ }
77
+
66
78
private string DebuggerDisplay
67
79
{
68
80
get
You can’t perform that action at this time.
0 commit comments