mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-10 20:05:50 +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:
parent
5b109b2dd6
commit
cb0c8f39bf
1 changed files with 13 additions and 18 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue