diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-10 16:05:21 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-11 17:07:49 +1000 |
commit | bfad972f0c75bb0fb4a60cf6848c1ab205254d87 (patch) | |
tree | 3cf26baa02c0233c45db7b66e4709989ea31edbe /pkg/commands | |
parent | bb918b579a3073d786fda83a2bc11c602e442aa0 (diff) |
fix bug where mixed reset is actually a soft reset
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/branches.go | 4 | ||||
-rw-r--r-- | pkg/commands/git.go | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/pkg/commands/branches.go b/pkg/commands/branches.go index cfc9803d6..62a243247 100644 --- a/pkg/commands/branches.go +++ b/pkg/commands/branches.go @@ -152,6 +152,10 @@ func (c *GitCommand) ResetSoft(ref string) error { return c.RunCommand("git reset --soft " + ref) } +func (c *GitCommand) ResetMixed(ref string) error { + return c.RunCommand("git reset --mixed " + ref) +} + func (c *GitCommand) RenameBranch(oldName string, newName string) error { return c.RunCommand("git branch --move %s %s", oldName, newName) } diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 2745c1935..db5585172 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -87,7 +87,13 @@ func (c *GitCommand) WithSpan(span string) *GitCommand { newGitCommand := &GitCommand{} *newGitCommand = *c newGitCommand.OSCommand = c.OSCommand.WithSpan(span) + + // NOTE: unlike the other things here which create shallow clones, this will + // actually update the PatchManager on the original struct to have the new span. + // This means each time we call ApplyPatch in PatchManager, we need to ensure + // we've called .WithSpan() ahead of time with the new span value newGitCommand.PatchManager.ApplyPatch = newGitCommand.ApplyPatch + return newGitCommand } |