mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
fix bug where mixed reset is actually a soft reset
This commit is contained in:
@ -152,6 +152,10 @@ func (c *GitCommand) ResetSoft(ref string) error {
|
|||||||
return c.RunCommand("git reset --soft " + ref)
|
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 {
|
func (c *GitCommand) RenameBranch(oldName string, newName string) error {
|
||||||
return c.RunCommand("git branch --move %s %s", oldName, newName)
|
return c.RunCommand("git branch --move %s %s", oldName, newName)
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,13 @@ func (c *GitCommand) WithSpan(span string) *GitCommand {
|
|||||||
newGitCommand := &GitCommand{}
|
newGitCommand := &GitCommand{}
|
||||||
*newGitCommand = *c
|
*newGitCommand = *c
|
||||||
newGitCommand.OSCommand = c.OSCommand.WithSpan(span)
|
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
|
newGitCommand.PatchManager.ApplyPatch = newGitCommand.ApplyPatch
|
||||||
|
|
||||||
return newGitCommand
|
return newGitCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ func (gui *Gui) handleCreateResetMenu() error {
|
|||||||
red.Sprint(nukeStr),
|
red.Sprint(nukeStr),
|
||||||
},
|
},
|
||||||
onPress: func() error {
|
onPress: func() error {
|
||||||
if err := gui.GitCommand.ResetAndClean(); err != nil {
|
if err := gui.GitCommand.WithSpan("Nuke working tree").ResetAndClean(); err != nil {
|
||||||
return gui.surfaceError(err)
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ func (gui *Gui) handleCreateResetMenu() error {
|
|||||||
red.Sprint("git checkout -- ."),
|
red.Sprint("git checkout -- ."),
|
||||||
},
|
},
|
||||||
onPress: func() error {
|
onPress: func() error {
|
||||||
if err := gui.GitCommand.DiscardAnyUnstagedFileChanges(); err != nil {
|
if err := gui.GitCommand.WithSpan("Discard unstaged file changes").DiscardAnyUnstagedFileChanges(); err != nil {
|
||||||
return gui.surfaceError(err)
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ func (gui *Gui) handleCreateResetMenu() error {
|
|||||||
red.Sprint("git clean -fd"),
|
red.Sprint("git clean -fd"),
|
||||||
},
|
},
|
||||||
onPress: func() error {
|
onPress: func() error {
|
||||||
if err := gui.GitCommand.RemoveUntrackedFiles(); err != nil {
|
if err := gui.GitCommand.WithSpan("Remove untracked files").RemoveUntrackedFiles(); err != nil {
|
||||||
return gui.surfaceError(err)
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ func (gui *Gui) handleCreateResetMenu() error {
|
|||||||
red.Sprint("git reset --soft HEAD"),
|
red.Sprint("git reset --soft HEAD"),
|
||||||
},
|
},
|
||||||
onPress: func() error {
|
onPress: func() error {
|
||||||
if err := gui.GitCommand.ResetSoft("HEAD"); err != nil {
|
if err := gui.GitCommand.WithSpan("Soft reset").ResetSoft("HEAD"); err != nil {
|
||||||
return gui.surfaceError(err)
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ func (gui *Gui) handleCreateResetMenu() error {
|
|||||||
red.Sprint("git reset --mixed HEAD"),
|
red.Sprint("git reset --mixed HEAD"),
|
||||||
},
|
},
|
||||||
onPress: func() error {
|
onPress: func() error {
|
||||||
if err := gui.GitCommand.ResetSoft("HEAD"); err != nil {
|
if err := gui.GitCommand.WithSpan("Mixed reset").ResetMixed("HEAD"); err != nil {
|
||||||
return gui.surfaceError(err)
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ func (gui *Gui) handleCreateResetMenu() error {
|
|||||||
red.Sprint("git reset --hard HEAD"),
|
red.Sprint("git reset --hard HEAD"),
|
||||||
},
|
},
|
||||||
onPress: func() error {
|
onPress: func() error {
|
||||||
if err := gui.GitCommand.ResetHard("HEAD"); err != nil {
|
if err := gui.GitCommand.WithSpan("Hard reset").ResetHard("HEAD"); err != nil {
|
||||||
return gui.surfaceError(err)
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user