@@ -117,18 +117,18 @@ public override Task<bool> Sure()
117
117
var updateSubmodules = IsRecurseSubmoduleVisible && RecurseSubmodules ;
118
118
return Task . Run ( ( ) =>
119
119
{
120
- bool succ ;
120
+ bool succ = false ;
121
121
if ( CheckoutAfterCreated && ! _repo . IsBare )
122
122
{
123
- var changes = new Commands . CountLocalChangesWithoutUntracked ( _repo . FullPath ) . Result ( ) ;
124
123
var needPopStash = false ;
125
- if ( changes > 0 )
124
+ if ( DiscardLocalChanges )
126
125
{
127
- if ( DiscardLocalChanges )
128
- {
129
- Commands . Discard . All ( _repo . FullPath , false , log ) ;
130
- }
131
- else
126
+ succ = new Commands . Checkout ( _repo . FullPath ) . Use ( log ) . Branch ( fixedName , _baseOnRevision , true ) ;
127
+ }
128
+ else
129
+ {
130
+ var changes = new Commands . CountLocalChangesWithoutUntracked ( _repo . FullPath ) . Result ( ) ;
131
+ if ( changes > 0 )
132
132
{
133
133
succ = new Commands . Stash ( _repo . FullPath ) . Use ( log ) . Push ( "CREATE_BRANCH_AUTO_STASH" ) ;
134
134
if ( ! succ )
@@ -140,18 +140,22 @@ public override Task<bool> Sure()
140
140
141
141
needPopStash = true ;
142
142
}
143
+
144
+ succ = new Commands . Checkout ( _repo . FullPath ) . Use ( log ) . Branch ( fixedName , _baseOnRevision , false ) ;
143
145
}
144
146
145
- succ = new Commands . Checkout ( _repo . FullPath ) . Use ( log ) . Branch ( fixedName , _baseOnRevision ) ;
146
- if ( succ && updateSubmodules )
147
+ if ( succ )
147
148
{
148
- var submodules = new Commands . QuerySubmodules ( _repo . FullPath ) . Result ( ) ;
149
- foreach ( var submodule in submodules )
150
- new Commands . Submodule ( _repo . FullPath ) . Use ( log ) . Update ( submodule . Path , true , true , false ) ;
151
- }
149
+ if ( updateSubmodules )
150
+ {
151
+ var submodules = new Commands . QuerySubmodules ( _repo . FullPath ) . Result ( ) ;
152
+ if ( submodules . Count > 0 )
153
+ new Commands . Submodule ( _repo . FullPath ) . Use ( log ) . Update ( submodules , true , true , false ) ;
154
+ }
152
155
153
- if ( succ && needPopStash )
154
- new Commands . Stash ( _repo . FullPath ) . Use ( log ) . Pop ( "stash@{0}" ) ;
156
+ if ( needPopStash )
157
+ new Commands . Stash ( _repo . FullPath ) . Use ( log ) . Pop ( "stash@{0}" ) ;
158
+ }
155
159
}
156
160
else
157
161
{
@@ -174,17 +178,16 @@ public override Task<bool> Sure()
174
178
175
179
if ( _repo . HistoriesFilterMode == Models . FilterMode . Included )
176
180
_repo . SetBranchFilterMode ( fake , Models . FilterMode . Included , true , false ) ;
181
+
182
+ ProgressDescription = "Waiting for branch updated..." ;
177
183
}
178
184
179
185
_repo . MarkBranchesDirtyManually ( ) ;
180
186
_repo . SetWatcherEnabled ( true ) ;
181
187
} ) ;
182
188
183
189
if ( CheckoutAfterCreated )
184
- {
185
- CallUIThread ( ( ) => ProgressDescription = "Waiting for branch updated..." ) ;
186
190
Task . Delay ( 400 ) . Wait ( ) ;
187
- }
188
191
189
192
return true ;
190
193
} ) ;
0 commit comments