mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-15 01:34:26 +02:00
Simplify code and fix comment
The "// merge commit" comment was plain wrong, this is any commit that has a parent, merge or not. The "else if" condition was unnecessary, a plain "else" would have been enough. But the code in the two blocks was almost identical, so extract the one thing that was different and unify it. And while we're at it, use IsFirstCommit() instead of counting parents.
This commit is contained in:
@ -133,25 +133,20 @@ func getNextPipes(prevPipes []*Pipe, commit *models.Commit, getStyle func(c *mod
|
||||
// a traversed spot is one where a current pipe is starting on, ending on, or passing through
|
||||
traversedSpots := set.New[int]()
|
||||
|
||||
if len(commit.Parents) > 0 { // merge commit
|
||||
newPipes = append(newPipes, &Pipe{
|
||||
fromPos: pos,
|
||||
toPos: pos,
|
||||
fromHash: commit.Hash,
|
||||
toHash: commit.Parents[0],
|
||||
kind: STARTS,
|
||||
style: getStyle(commit),
|
||||
})
|
||||
} else if len(commit.Parents) == 0 { // root commit
|
||||
newPipes = append(newPipes, &Pipe{
|
||||
fromPos: pos,
|
||||
toPos: pos,
|
||||
fromHash: commit.Hash,
|
||||
toHash: models.EmptyTreeCommitHash,
|
||||
kind: STARTS,
|
||||
style: getStyle(commit),
|
||||
})
|
||||
var toHash string
|
||||
if commit.IsFirstCommit() {
|
||||
toHash = models.EmptyTreeCommitHash
|
||||
} else {
|
||||
toHash = commit.Parents[0]
|
||||
}
|
||||
newPipes = append(newPipes, &Pipe{
|
||||
fromPos: pos,
|
||||
toPos: pos,
|
||||
fromHash: commit.Hash,
|
||||
toHash: toHash,
|
||||
kind: STARTS,
|
||||
style: getStyle(commit),
|
||||
})
|
||||
|
||||
traversedSpotsForContinuingPipes := set.New[int]()
|
||||
for _, pipe := range currentPipes {
|
||||
|
Reference in New Issue
Block a user