summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-02-26 13:20:10 +0100
committerStefan Haller <stefan@haller-berlin.de>2023-03-07 09:49:34 +0100
commitf76cc2795601a14ce8e622a28f1d9f94028a3d06 (patch)
tree0e95e000368e6e138614c06d77285094f47737c5 /pkg/gui
parent5a50bfd1792f1518c3442ebfec836ce95b785683 (diff)
Bundle the reverse and keepOriginalHeader flags into a PatchOptions struct
We are going to add one more flag in the next commit. Note that we are not using the struct inside patch_manager.go; we keep passing the individual flags there. The reason for this will become more obvious later in this branch.
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/controllers/staging_controller.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go
index 0cddfb841..840c18a18 100644
--- a/pkg/gui/controllers/staging_controller.go
+++ b/pkg/gui/controllers/staging_controller.go
@@ -181,7 +181,8 @@ func (self *StagingController) applySelection(reverse bool) error {
}
firstLineIdx, lastLineIdx := state.SelectedRange()
- patch := patch.ModifiedPatchForRange(self.c.Log, path, state.GetDiff(), firstLineIdx, lastLineIdx, reverse, false)
+ patch := patch.ModifiedPatchForRange(self.c.Log, path, state.GetDiff(), firstLineIdx, lastLineIdx,
+ patch.PatchOptions{Reverse: reverse, KeepOriginalHeader: false})
if patch == "" {
return nil
@@ -227,7 +228,8 @@ func (self *StagingController) editHunk() error {
hunk := state.CurrentHunk()
patchText := patch.ModifiedPatchForRange(
- self.c.Log, path, state.GetDiff(), hunk.FirstLineIdx, hunk.LastLineIdx(), self.staged, false,
+ self.c.Log, path, state.GetDiff(), hunk.FirstLineIdx, hunk.LastLineIdx(),
+ patch.PatchOptions{Reverse: self.staged, KeepOriginalHeader: false},
)
patchFilepath, err := self.git.WorkingTree.SaveTemporaryPatch(patchText)
if err != nil {
@@ -249,7 +251,8 @@ func (self *StagingController) editHunk() error {
lineCount := strings.Count(editedPatchText, "\n") + 1
newPatchText := patch.ModifiedPatchForRange(
- self.c.Log, path, editedPatchText, 0, lineCount, false, false,
+ self.c.Log, path, editedPatchText, 0, lineCount,
+ patch.PatchOptions{Reverse: false, KeepOriginalHeader: false},
)
if err := self.git.WorkingTree.ApplyPatch(newPatchText, "cached"); err != nil {
return self.c.Error(err)