11import * as React from 'react'
2- import * as Path from 'path'
32
43import { Branch } from '../../models/branch'
5- import { WorktreeEntry } from '../../models/worktree'
64
75import { assertNever } from '../../lib/fatal-error'
86
@@ -54,11 +52,6 @@ interface IBranchListProps {
5452 */
5553 readonly recentBranches : ReadonlyArray < Branch >
5654
57- /**
58- * All worktrees in the repository.
59- */
60- readonly allWorktrees : ReadonlyArray < WorktreeEntry >
61-
6255 /**
6356 * The sort order for branch lists in the current user preferences.
6457 */
@@ -195,9 +188,9 @@ export class BranchList extends React.Component<IBranchListProps> {
195188 private get groups ( ) {
196189 return this . getGroups (
197190 this . props . defaultBranch ,
191+ this . props . currentBranch ,
198192 this . props . allBranches ,
199193 this . props . recentBranches ,
200- this . props . allWorktrees ,
201194 this . props . branchSortOrder
202195 )
203196 }
@@ -311,20 +304,17 @@ export class BranchList extends React.Component<IBranchListProps> {
311304 ) : JSX . Element | string | null => {
312305 const { tip, name } = item . branch
313306
314- const absoluteDate = formatDate ( tip . author . date , {
315- dateStyle : 'full' ,
316- timeStyle : 'short' ,
317- } )
307+ const authorDate = tip . author . date
308+
309+ const absoluteDate = authorDate
310+ ? formatDate ( authorDate , {
311+ dateStyle : 'full' ,
312+ timeStyle : 'short' ,
313+ } )
314+ : null
318315
319- const otherWorktreeName = this . inUseByOtherWorktreeName ( item )
320316 return (
321317 < div className = "branches-list-item-tooltip list-item-tooltip" >
322- { otherWorktreeName && (
323- < div className = "label tooltip-warning" >
324- This branch cannot be checked out because it is in use by worktree
325- "{ otherWorktreeName } "
326- </ div >
327- ) }
328318 < div >
329319 < div className = "label" > Full Name: </ div >
330320 { name }
@@ -339,17 +329,6 @@ export class BranchList extends React.Component<IBranchListProps> {
339329 )
340330 }
341331
342- private inUseByOtherWorktreeName ( item : IBranchListItem ) : string | null {
343- const worktreeName = item . worktreeInUse
344- ? Path . basename ( item . worktreeInUse . path )
345- : null
346-
347- return worktreeName !== null &&
348- this . props . currentBranch ?. name !== item . branch . name
349- ? worktreeName
350- : null
351- }
352-
353332 private parseHeader ( label : string ) : BranchGroupIdentifier | null {
354333 switch ( label ) {
355334 case 'default' :
@@ -415,16 +394,6 @@ export class BranchList extends React.Component<IBranchListProps> {
415394 }
416395
417396 private onItemClick = ( item : IBranchListItem , source : ClickSource ) => {
418- // Don't allow clicking branches that are in use by other worktrees
419- if ( item . worktreeInUse !== null ) {
420- const currentBranch = this . props . currentBranch
421- const isCurrentBranch =
422- currentBranch !== null && currentBranch . name === item . branch . name
423- if ( ! isCurrentBranch ) {
424- return
425- }
426- }
427-
428397 if ( this . props . onItemClick ) {
429398 this . props . onItemClick ( item . branch , source )
430399 }
@@ -434,18 +403,6 @@ export class BranchList extends React.Component<IBranchListProps> {
434403 selectedItem : IBranchListItem | null ,
435404 source : SelectionSource
436405 ) => {
437- // Don't allow selecting branches that are in use by other worktrees
438- if ( selectedItem ?. worktreeInUse !== null ) {
439- const currentBranch = this . props . currentBranch
440- const isCurrentBranch =
441- currentBranch !== null &&
442- selectedItem !== null &&
443- currentBranch . name === selectedItem . branch . name
444- if ( ! isCurrentBranch ) {
445- return
446- }
447- }
448-
449406 if ( this . props . onSelectionChanged ) {
450407 this . props . onSelectionChanged (
451408 selectedItem ? selectedItem . branch : null ,
0 commit comments