mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
do not show commit files of another parent as added to the patch
This commit is contained in:
@ -222,7 +222,11 @@ func (p *PatchManager) RenderAggregatedPatchColored(plain bool) string {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PatchManager) GetFileStatus(filename string) PatchStatus {
|
func (p *PatchManager) GetFileStatus(filename string, parent string) PatchStatus {
|
||||||
|
if parent != p.To {
|
||||||
|
return UNSELECTED
|
||||||
|
}
|
||||||
|
|
||||||
info, ok := p.fileInfoMap[filename]
|
info, ok := p.fileInfoMap[filename]
|
||||||
if !ok {
|
if !ok {
|
||||||
return UNSELECTED
|
return UNSELECTED
|
||||||
|
@ -148,7 +148,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
|
|||||||
// if there is any file that hasn't been fully added we'll fully add everything,
|
// if there is any file that hasn't been fully added we'll fully add everything,
|
||||||
// otherwise we'll remove everything
|
// otherwise we'll remove everything
|
||||||
adding := node.AnyFile(func(file *models.CommitFile) bool {
|
adding := node.AnyFile(func(file *models.CommitFile) bool {
|
||||||
return gui.GitCommand.PatchManager.GetFileStatus(file.Name) != patch.WHOLE
|
return gui.GitCommand.PatchManager.GetFileStatus(file.Name, gui.State.CommitFileChangeManager.GetParent()) != patch.WHOLE
|
||||||
})
|
})
|
||||||
|
|
||||||
err := node.ForEachFile(func(file *models.CommitFile) error {
|
err := node.ForEachFile(func(file *models.CommitFile) error {
|
||||||
|
@ -91,6 +91,6 @@ func (m *CommitFileChangeManager) ToggleCollapsed(path string) {
|
|||||||
func (m *CommitFileChangeManager) Render(diffName string, patchManager *patch.PatchManager) []string {
|
func (m *CommitFileChangeManager) Render(diffName string, patchManager *patch.PatchManager) []string {
|
||||||
return renderAux(m.tree, m.collapsedPaths, "", -1, func(n INode, depth int) string {
|
return renderAux(m.tree, m.collapsedPaths, "", -1, func(n INode, depth int) string {
|
||||||
castN := n.(*CommitFileChangeNode)
|
castN := n.(*CommitFileChangeNode)
|
||||||
return presentation.GetCommitFileLine(castN.NameAtDepth(depth), diffName, castN.File, patchManager)
|
return presentation.GetCommitFileLine(castN.NameAtDepth(depth), diffName, castN.File, patchManager, m.parent)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile, patchManager *patch.PatchManager) string {
|
func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile, patchManager *patch.PatchManager, parent string) string {
|
||||||
yellow := color.New(color.FgYellow)
|
yellow := color.New(color.FgYellow)
|
||||||
green := color.New(color.FgGreen)
|
green := color.New(color.FgGreen)
|
||||||
defaultColor := color.New(theme.DefaultTextColor)
|
defaultColor := color.New(theme.DefaultTextColor)
|
||||||
@ -22,7 +22,7 @@ func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFi
|
|||||||
if diffName == name {
|
if diffName == name {
|
||||||
colour = diffTerminalColor
|
colour = diffTerminalColor
|
||||||
} else if commitFile != nil {
|
} else if commitFile != nil {
|
||||||
status := patchManager.GetFileStatus(commitFile.Name)
|
status := patchManager.GetFileStatus(commitFile.Name, parent)
|
||||||
switch status {
|
switch status {
|
||||||
case patch.UNSELECTED:
|
case patch.UNSELECTED:
|
||||||
colour = defaultColor
|
colour = defaultColor
|
||||||
|
Reference in New Issue
Block a user