@@ -117,18 +117,18 @@ public override Task<bool> Sure()
117117 var updateSubmodules = IsRecurseSubmoduleVisible && RecurseSubmodules ;
118118 return Task . Run ( ( ) =>
119119 {
120- bool succ ;
120+ bool succ = false ;
121121 if ( CheckoutAfterCreated && ! _repo . IsBare )
122122 {
123- var changes = new Commands . CountLocalChangesWithoutUntracked ( _repo . FullPath ) . Result ( ) ;
124123 var needPopStash = false ;
125- if ( changes > 0 )
124+ if ( DiscardLocalChanges )
126125 {
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 )
132132 {
133133 succ = new Commands . Stash ( _repo . FullPath ) . Use ( log ) . Push ( "CREATE_BRANCH_AUTO_STASH" ) ;
134134 if ( ! succ )
@@ -140,18 +140,22 @@ public override Task<bool> Sure()
140140
141141 needPopStash = true ;
142142 }
143+
144+ succ = new Commands . Checkout ( _repo . FullPath ) . Use ( log ) . Branch ( fixedName , _baseOnRevision , false ) ;
143145 }
144146
145- succ = new Commands . Checkout ( _repo . FullPath ) . Use ( log ) . Branch ( fixedName , _baseOnRevision ) ;
146- if ( succ && updateSubmodules )
147+ if ( succ )
147148 {
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+ }
152155
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+ }
155159 }
156160 else
157161 {
@@ -174,17 +178,16 @@ public override Task<bool> Sure()
174178
175179 if ( _repo . HistoriesFilterMode == Models . FilterMode . Included )
176180 _repo . SetBranchFilterMode ( fake , Models . FilterMode . Included , true , false ) ;
181+
182+ ProgressDescription = "Waiting for branch updated..." ;
177183 }
178184
179185 _repo . MarkBranchesDirtyManually ( ) ;
180186 _repo . SetWatcherEnabled ( true ) ;
181187 } ) ;
182188
183189 if ( CheckoutAfterCreated )
184- {
185- CallUIThread ( ( ) => ProgressDescription = "Waiting for branch updated..." ) ;
186190 Task . Delay ( 400 ) . Wait ( ) ;
187- }
188191
189192 return true ;
190193 } ) ;
0 commit comments