summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-02-23 18:45:38 +0100
committerStefan Haller <stefan@haller-berlin.de>2023-03-07 09:49:34 +0100
commit5d692e89610166fc0c4458de8b4f5acabc6e4b6f (patch)
treecb552085b6b1f4360836f6075590adc0bc54ef2f /pkg
parent9cc33c479b6da6ef0db46ebf5a75e8b06c39310e (diff)
Remove the keepOriginalHeader retry loop
The loop is pointless for two reasons: - git apply --3way has this fallback built in already. If it can't do a three-way merge, it will fall back to applying the patch normally. - However, the only situation where it does this is when it can't do a 3-way merge at all because it can't find the necessary ancestor blob. This can only happen if you transfer a patch between different repos that don't have the same blobs available; we are applying the patch to the same repo that is was just generated from, so a 3-way merge is always possible. (Now that we fixed the bug in the previous commit, that is.) But the retry loop is not only pointless, it was actually harmful, because when a 3-way patch fails with a conflict, git will put conflict markers in the patched file and then exit with a non-zero exit status. So the retry loop would try to patch the already patched file again, and this almost certainly fails, but with a cryptic error message such as "error: main.go: does not exist in index".
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/patch/patch_manager.go19
1 files changed, 5 insertions, 14 deletions
diff --git a/pkg/commands/patch/patch_manager.go b/pkg/commands/patch/patch_manager.go
index a4b61dcd6..7e1721b7f 100644
--- a/pkg/commands/patch/patch_manager.go
+++ b/pkg/commands/patch/patch_manager.go
@@ -255,21 +255,12 @@ func (p *PatchManager) ApplyPatches(reverse bool) error {
continue
}
- var err error
- // first run we try with the original header, then without
- for _, keepOriginalHeader := range []bool{true, false} {
- patch := p.RenderPatchForFile(filename, true, false, reverse, keepOriginalHeader)
- if patch == "" {
- continue
- }
- if err = p.applyPatch(patch, applyFlags...); err != nil {
- continue
+ patch := p.RenderPatchForFile(filename, true, false, reverse, true)
+ if patch != "" {
+ err := p.applyPatch(patch, applyFlags...)
+ if err != nil {
+ return err
}
- break
- }
-
- if err != nil {
- return err
}
}