summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorGiorgio Previtera <gprevitera@equalexperts.com>2019-07-13 13:57:35 +0100
committerJesse Duffield <jessedduffield@gmail.com>2019-07-27 11:05:23 +1000
commit212327d746ecc956233e4f622d65d0568f6beea3 (patch)
tree040669622876b119d6e6cccf09f725180c07e8fc /pkg/commands
parentcc138fc70eaf135d796e666cc2988698f5d4d4ef (diff)
#477 Discard changes when there are merge conflicts
If there are merge conflicts, reset the file and discard all changes
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index c767b5917..4e416310e 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -471,11 +471,17 @@ func (c *GitCommand) RebaseMode() (string, error) {
func (c *GitCommand) DiscardAllFileChanges(file *File) error {
// if the file isn't tracked, we assume you want to delete it
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 {
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 {
return c.removeFile(file.Name)
}