mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-08-28 10:15:32 -05:00
The worktrees tab now displays the checked-out branch (or detached HEAD state) for each worktree, making it much easier to see which worktree holds which branch. This is useful when you need to "unlock" a branch that's occupied by another worktree: you can now clearly see which worktrees are on a branch vs detached, without having to select each one individually. Also rename the "(main)" label to "(main worktree)" to avoid confusion with the common "main" branch name, and move it after the branch column.
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package models
|
|
|
|
// A git worktree
|
|
type Worktree struct {
|
|
// if false, this is a linked worktree
|
|
IsMain bool
|
|
// if true, this is the worktree that is currently checked out
|
|
IsCurrent bool
|
|
// path to the directory of the worktree i.e. the directory that contains all the user's files
|
|
Path string
|
|
// if true, the path is not found
|
|
IsPathMissing bool
|
|
// path of the git directory for this worktree. The equivalent of the .git directory
|
|
// in the main worktree. For linked worktrees this would be <repo_path>/.git/worktrees/<name>
|
|
GitDir string
|
|
// If the worktree has a branch checked out, this field will be set to the branch name.
|
|
// A branch is considered 'checked out' if:
|
|
// * the worktree is directly on the branch
|
|
// * the worktree is mid-rebase on the branch
|
|
// * the worktree is mid-bisect on the branch
|
|
Branch string
|
|
// The HEAD sha of the worktree. Always populated (even when Branch is set).
|
|
// Used for display when Branch is empty (detached HEAD state).
|
|
Head string
|
|
// based on the path, but uniquified. Not the same name that git uses in the worktrees/ folder (no good reason for this,
|
|
// I just prefer my naming convention better)
|
|
Name string
|
|
}
|
|
|
|
func (w *Worktree) RefName() string {
|
|
return w.Name
|
|
}
|
|
|
|
func (w *Worktree) ID() string {
|
|
return w.Path
|
|
}
|
|
|
|
func (w *Worktree) Description() string {
|
|
return w.RefName()
|
|
}
|