File tree Expand file tree Collapse file tree 1 file changed +11
-21
lines changed
Expand file tree Collapse file tree 1 file changed +11
-21
lines changed Original file line number Diff line number Diff line change @@ -242,37 +242,27 @@ public async Task<bool> CheckoutBranchByDecoratorAsync(Models.Decorator decorato
242242
243243 public async Task CheckoutBranchByCommitAsync ( Models . Commit commit )
244244 {
245+ if ( commit == null )
246+ return ;
247+
245248 if ( commit . IsCurrentHead )
246249 return ;
247250
248251 Models . Branch firstRemoteBranch = null ;
249252 foreach ( var d in commit . Decorators )
250253 {
251- if ( d . Type == Models . DecoratorType . LocalBranchHead )
252- {
253- var b = _repo . Branches . Find ( x => x . Name == d . Name ) ;
254- if ( b == null )
255- continue ;
256-
257- await _repo . CheckoutBranchAsync ( b ) ;
258- return ;
259- }
260-
261- if ( d . Type == Models . DecoratorType . RemoteBranchHead )
254+ if ( d . Type == Models . DecoratorType . LocalBranchHead || d . Type == Models . DecoratorType . RemoteBranchHead )
262255 {
263- var rb = _repo . Branches . Find ( x => x . FriendlyName == d . Name ) ;
264- if ( rb == null )
265- continue ;
256+ var handled = await CheckoutBranchByDecoratorAsync ( d ) ;
257+ if ( handled )
258+ return ;
266259
267- var lb = _repo . Branches . Find ( x => x . IsLocal && x . Upstream == rb . FullName ) ;
268- if ( lb . Ahead . Count == 0 )
260+ if ( d . Type == Models . DecoratorType . RemoteBranchHead )
269261 {
270- if ( _repo . CanCreatePopup ( ) )
271- _repo . ShowPopup ( new CheckoutAndFastForward ( _repo , lb , rb ) ) ;
272- return ;
262+ var rb = _repo . Branches . Find ( x => x . FriendlyName == d . Name ) ;
263+ if ( rb != null && firstRemoteBranch == null )
264+ firstRemoteBranch = rb ;
273265 }
274-
275- firstRemoteBranch ??= rb ;
276266 }
277267 }
278268
You can’t perform that action at this time.
0 commit comments