@@ -58,6 +58,8 @@ public CreateBranch(Repository repo, Models.Branch branch)
5858 {
5959 _repo = repo ;
6060 _baseOnRevision = branch . Head ;
61+ _committerDate = branch . CommitterDate ;
62+ _head = branch . Head ;
6163
6264 if ( ! branch . IsLocal )
6365 Name = branch . Name ;
@@ -70,6 +72,8 @@ public CreateBranch(Repository repo, Models.Commit commit)
7072 {
7173 _repo = repo ;
7274 _baseOnRevision = commit . SHA ;
75+ _committerDate = commit . CommitterTime ;
76+ _head = commit . SHA ;
7377
7478 BasedOn = commit ;
7579 DiscardLocalChanges = false ;
@@ -79,6 +83,8 @@ public CreateBranch(Repository repo, Models.Tag tag)
7983 {
8084 _repo = repo ;
8185 _baseOnRevision = tag . SHA ;
86+ _committerDate = tag . CreatorDate ;
87+ _head = tag . SHA ;
8288
8389 BasedOn = tag ;
8490 DiscardLocalChanges = false ;
@@ -125,6 +131,15 @@ public override async Task<bool> Sure()
125131 }
126132 }
127133
134+ Models . Branch created = new ( )
135+ {
136+ Name = _name ,
137+ FullName = $ "refs/heads/{ _name } ",
138+ CommitterDate = _committerDate ,
139+ Head = _head ,
140+ IsLocal = true ,
141+ } ;
142+
128143 bool succ ;
129144 if ( CheckoutAfterCreated && ! _repo . IsBare )
130145 {
@@ -168,43 +183,33 @@ public override async Task<bool> Sure()
168183 . CreateAsync ( _baseOnRevision , _allowOverwrite ) ;
169184 }
170185
171- if ( succ && BasedOn is Models . Branch { IsLocal : false } basedOn && _name . Equals ( basedOn . Name , StringComparison . Ordinal ) )
186+ if ( succ )
172187 {
173- await new Commands . Branch ( _repo . FullPath , _name )
188+ if ( BasedOn is Models . Branch { IsLocal : false } basedOn && _name . Equals ( basedOn . Name , StringComparison . Ordinal ) )
189+ {
190+ await new Commands . Branch ( _repo . FullPath , _name )
174191 . Use ( log )
175192 . SetUpstreamAsync ( basedOn ) ;
176- }
177-
178- log . Complete ( ) ;
179-
180- if ( succ && CheckoutAfterCreated )
181- {
182- var fake = new Models . Branch ( ) { IsLocal = true , FullName = $ "refs/heads/{ _name } " } ;
183- if ( BasedOn is Models . Branch { IsLocal : false } based )
184- fake . Upstream = based . FullName ;
185193
186- var folderEndIdx = fake . FullName . LastIndexOf ( '/' ) ;
187- if ( folderEndIdx > 10 )
188- _repo . UIStates . ExpandedBranchNodesInSideBar . Add ( fake . FullName . Substring ( 0 , folderEndIdx ) ) ;
194+ created . Upstream = basedOn . FullName ;
195+ }
189196
190- if ( _repo . HistoryFilterMode == Models . FilterMode . Included )
191- _repo . SetBranchFilterMode ( fake , Models . FilterMode . Included , false , false ) ;
197+ _repo . RefreshAfterCreateBranch ( created , CheckoutAfterCreated ) ;
192198 }
193-
194- _repo . MarkBranchesDirtyManually ( ) ;
195-
196- if ( CheckoutAfterCreated )
199+ else
197200 {
198- ProgressDescription = "Waiting for branch updated..." ;
199- await Task . Delay ( 400 ) ;
201+ _repo . MarkWorkingCopyDirtyManually ( ) ;
200202 }
201203
204+ log . Complete ( ) ;
202205 return true ;
203206 }
204207
205208 private readonly Repository _repo = null ;
206- private string _name = null ;
207209 private readonly string _baseOnRevision = null ;
210+ private readonly ulong _committerDate = 0 ;
211+ private readonly string _head = string . Empty ;
212+ private string _name = null ;
208213 private bool _allowOverwrite = false ;
209214 }
210215}
0 commit comments