mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-09 13:47:11 +02:00
#477 Discard changes when there are merge conflicts
If there are merge conflicts, reset the file and discard all changes
This commit is contained in:
parent
cc138fc70e
commit
212327d746
@ -471,11 +471,17 @@ func (c *GitCommand) RebaseMode() (string, error) {
|
|||||||
func (c *GitCommand) DiscardAllFileChanges(file *File) error {
|
func (c *GitCommand) DiscardAllFileChanges(file *File) error {
|
||||||
// if the file isn't tracked, we assume you want to delete it
|
// if the file isn't tracked, we assume you want to delete it
|
||||||
quotedFileName := c.OSCommand.Quote(file.Name)
|
quotedFileName := c.OSCommand.Quote(file.Name)
|
||||||
if file.HasStagedChanges {
|
if file.HasStagedChanges || file.HasMergeConflicts || file.HasInlineMergeConflicts {
|
||||||
if err := c.OSCommand.RunCommand(fmt.Sprintf("git reset -- %s", quotedFileName)); err != nil {
|
if err := c.OSCommand.RunCommand(fmt.Sprintf("git reset -- %s", quotedFileName)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if file.HasMergeConflicts || file.HasInlineMergeConflicts {
|
||||||
|
if err := c.OSCommand.RunCommand(fmt.Sprintf("git checkout -- %s", quotedFileName)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !file.Tracked {
|
if !file.Tracked {
|
||||||
return c.removeFile(file.Name)
|
return c.removeFile(file.Name)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user