summaryrefslogtreecommitdiffstats
path: root/pkg/commands/patch
AgeCommit message (Collapse)Author
2023-07-30Standardise on using lo for slice functionsJesse Duffield
We've been sometimes using lo and sometimes using my slices package, and we need to pick one for consistency. Lo is more extensive and better maintained so we're going with that. My slices package was a superset of go's own slices package so in some places I've just used the official one (the methods were just wrappers anyway). I've also moved the remaining methods into the utils package.
2023-05-20Refactor interface for ApplyPatchJesse Duffield
2023-03-19rename patch manager to patch builderJesse Duffield
2023-03-19refactor patch codeJesse Duffield
2023-03-18Fix "move patch into new commit" for partial hunk (#2507)Stefan Haller
2023-03-08Add more unit testsJesse Duffield
2023-03-07Rename WillBeAppliedReverse to ReverseStefan Haller
This is the only "reverse"-related option that is left, so use a less clumsy name for it.
2023-03-07Remove the PatchOptions.Reverse optionStefan Haller
All callers pass false now (except for the tests, which we simply remove), so we don't need the option any more.
2023-03-07Concatenate patches to apply them all at onceStefan Haller
This fixes the problem that patching would stop at the first file that has a conflict. We always want to patch all files. Also, it's faster for large patches, and the code is a little bit simpler too.
2023-03-07Remove parameters that are no longer neededStefan Haller
All callers in this file now use reverseOnGenerate=false and keepOriginalHeader=true, so hard-code that in the call to ModifiedPatchForLines and get rid of the parameters.
2023-03-07Remove the keepOriginalHeader retry loopStefan Haller
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".
2023-03-07Use forward patches and --reverse flag for partial patches tooStefan Haller
There's no reason to have two different ways of applying patches for whole-file patches and partial patches; use --reverse for both. Not only does this simplify the code a bit, but it fixes an actual problem: when reverseOnGenerate and keepOriginalHeader are both true, the generated patch header is broken (the two blobs in the line `index 6d1959b..6dc5f84 100644` are swapped). Git fails to do a proper three-way merge in that case, as it expects the first of the two blobs to be the common ancestor. It would be possible to fix this by extending ModifiedPatchForLines to swap the two blobs in this case; but this would prevent us from concatenating all patches and apply them in one go, which we are going to do later in the branch.
2023-03-07Add patch option WillBeAppliedReverseStefan Haller
It's not used yet, but covered with tests already.
2023-03-07Bundle the reverse and keepOriginalHeader flags into a PatchOptions structStefan Haller
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.
2023-02-25Improve staging panel integration testsJesse Duffield
2023-01-26Don't omit final line feed when copying diff lines to clipboardstk
2023-01-26Cleanup: remove unused function RenderPlainstk
2022-08-06refactor to only have one context per viewJesse Duffield
2022-03-24would you believe that I'm adding even more genericsJesse Duffield
2022-03-24more genericsJesse Duffield
2022-03-24make more use of genericsJesse Duffield
2022-03-19update lintersJesse Duffield
2022-01-09add some more lintersJesse Duffield
2022-01-07privatise some fieldsJesse Duffield
2021-10-16minor changesJesse Duffield
2021-10-16copy selected text to clipboardHrishikesh Hiraskar
2021-08-04fix backward compatibilityRyooooooga
2021-08-03fix out of range errorRyooooooga
2021-08-01color fixupsJesse Duffield
2021-07-31simplify code a bitJesse Duffield
2021-07-30Switch to github.com/gookit/color for terminal colorsmjarkk
2021-04-18refactor line by line panelJesse Duffield
2021-04-02big refactor to give our enums actual typesJesse Duffield
2021-04-02do not show commit files of another parent as added to the patchJesse Duffield
2021-04-02refactorJesse Duffield
2020-08-23cleanupJesse Duffield
2020-08-23remove todo commentJesse Duffield
2020-08-23support creating patches from files in diff modeJesse Duffield
2020-08-23don't needlessly load every fileJesse Duffield
2020-08-23faster patch managerJesse Duffield
2020-08-23refactorJesse Duffield
2020-08-23generalise patch building stuffJesse Duffield
2020-08-15move patch stuff into its own packageJesse Duffield