mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
Initial addition of support for worktrees
This commit is contained in:
parent
52447e5d46
commit
f8ba899b87
20 changed files with 439 additions and 0 deletions
|
@ -2,6 +2,7 @@ package git_commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
|
@ -117,6 +118,11 @@ outer:
|
|||
}
|
||||
|
||||
func (self *BranchLoader) obtainBranches() []*models.Branch {
|
||||
currentDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
output, err := self.getRawBranches()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -138,6 +144,11 @@ func (self *BranchLoader) obtainBranches() []*models.Branch {
|
|||
return nil, false
|
||||
}
|
||||
|
||||
if len(split[6]) > 0 && split[6] != currentDir {
|
||||
// Ignore line because it is a branch checked out in a different worktree
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return obtainBranch(split), true
|
||||
})
|
||||
}
|
||||
|
@ -166,6 +177,7 @@ var branchFields = []string{
|
|||
"upstream:track",
|
||||
"subject",
|
||||
fmt.Sprintf("objectname:short=%d", utils.COMMIT_HASH_SHORT_SIZE),
|
||||
"worktreepath",
|
||||
}
|
||||
|
||||
// Obtain branch information from parsed line output of getRawBranches()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue