summaryrefslogtreecommitdiffstats
path: root/pkg/gui/commit_files_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-22 18:29:09 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commit43d891b8d68c862da793429e0bdbca9dcabb44b0 (patch)
tree91ca072ea2d91eb156bd8c1958f8dbeb65c31c66 /pkg/gui/commit_files_panel.go
parent2eee079d3aafb7914947e85fe5decd528c34ab93 (diff)
support creating patches from files in diff mode
Diffstat (limited to 'pkg/gui/commit_files_panel.go')
-rw-r--r--pkg/gui/commit_files_panel.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go
index 134607434..442df823a 100644
--- a/pkg/gui/commit_files_panel.go
+++ b/pkg/gui/commit_files_panel.go
@@ -38,8 +38,11 @@ func (gui *Gui) handleCommitFileSelect() error {
return nil
}
+ to := commitFile.Parent
+ from, reverse := gui.getFromAndReverseArgsForDiff(to)
+
cmd := gui.OSCommand.ExecutableFromString(
- gui.GitCommand.ShowCommitFileCmdStr(commitFile.Parent, commitFile.Name, false),
+ gui.GitCommand.ShowFileDiffCmdStr(from, to, reverse, commitFile.Name, false),
)
task := gui.createRunPtyTask(cmd)
@@ -167,7 +170,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
return gui.refreshCommitFilesView()
}
- if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.Parent != commitFile.Parent {
+ if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.To != commitFile.Parent {
return gui.ask(askOpts{
returnToView: v,
returnFocusOnClose: true,
@@ -185,7 +188,11 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) startPatchManager() error {
canRebase := gui.State.Panels.CommitFiles.refType == REF_TYPE_LOCAL_COMMIT
- gui.GitCommand.PatchManager.Start(gui.State.Panels.CommitFiles.refName, canRebase)
+
+ to := gui.State.Panels.CommitFiles.refName
+ from, reverse := gui.getFromAndReverseArgsForDiff(to)
+
+ gui.GitCommand.PatchManager.Start(from, to, reverse, canRebase)
return nil
}
@@ -217,7 +224,7 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error {
return gui.refreshPatchBuildingPanel(selectedLineIdx)
}
- if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.Parent != commitFile.Parent {
+ if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.To != commitFile.Parent {
return gui.ask(askOpts{
returnToView: gui.getCommitFilesView(),
returnFocusOnClose: false,