1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
Commit Graph

43 Commits

Author SHA1 Message Date
Jesse Duffield
e33fe37a99 Standardise on using lo for slice functions
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-07-30 18:51:23 +10:00
Jesse Duffield
ee11046d35 Refactor interface for ApplyPatch 2023-05-20 20:54:39 +10:00
Jesse Duffield
60f902f026 rename patch manager to patch builder 2023-03-19 16:35:57 +11:00
Jesse Duffield
73c7dc9c5d refactor patch code 2023-03-19 16:30:39 +11:00
Stefan Haller
4b4dccfd7d
Fix "move patch into new commit" for partial hunk (#2507) 2023-03-18 18:17:47 +11:00
Jesse Duffield
0bda93d4c3 Add more unit tests 2023-03-08 09:19:23 +11:00
Stefan Haller
4bd1322941 Rename WillBeAppliedReverse to Reverse
This is the only "reverse"-related option that is left, so use a less clumsy
name for it.
2023-03-07 13:40:07 +01:00
Stefan Haller
45cf993982 Remove the PatchOptions.Reverse option
All callers pass false now (except for the tests, which we simply remove), so we
don't need the option any more.
2023-03-07 13:39:45 +01:00
Stefan Haller
a68cd6af9c Concatenate patches to apply them all at once
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-07 09:49:34 +01:00
Stefan Haller
6bd1c1d068 Remove parameters that are no longer needed
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-07 09:49:34 +01:00
Stefan Haller
5d692e8961 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".
2023-03-07 09:49:34 +01:00
Stefan Haller
9cc33c479b Use forward patches and --reverse flag for partial patches too
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-07 09:49:34 +01:00
Stefan Haller
c79e360584 Add patch option WillBeAppliedReverse
It's not used yet, but covered with tests already.
2023-03-07 09:49:34 +01:00
Stefan Haller
f76cc27956 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.
2023-03-07 09:49:34 +01:00
Jesse Duffield
db011d8e34 Improve staging panel integration tests 2023-02-25 11:35:41 +11:00
stk
fc38e3b54d Don't omit final line feed when copying diff lines to clipboard 2023-01-26 10:30:05 +01:00
stk
93d845cb01 Cleanup: remove unused function RenderPlain 2023-01-26 10:30:05 +01:00
Jesse Duffield
524bf83a4a refactor to only have one context per view 2022-08-06 13:49:11 +10:00
Jesse Duffield
94a53484a1 would you believe that I'm adding even more generics 2022-03-24 20:14:41 +11:00
Jesse Duffield
bf4f06ab4e more generics 2022-03-24 20:14:41 +11:00
Jesse Duffield
c7a629c440 make more use of generics 2022-03-24 20:14:41 +11:00
Jesse Duffield
a34bdf1a04 update linters 2022-03-19 12:12:57 +11:00
Jesse Duffield
18f48a43d5 add some more linters 2022-01-09 14:09:53 +11:00
Jesse Duffield
bbb5eee23a privatise some fields 2022-01-07 10:52:51 +11:00
Jesse Duffield
87e9d9bdc2 minor changes 2021-10-16 21:18:43 +11:00
Hrishikesh Hiraskar
b6454755ca copy selected text to clipboard 2021-10-16 21:18:43 +11:00
Ryooooooga
ac609bd37c
fix backward compatibility 2021-08-04 18:43:34 +09:00
Ryooooooga
67cc65930a
fix out of range error 2021-08-03 22:00:28 +09:00
Jesse Duffield
d626bcac00 color fixups 2021-08-01 16:14:56 +10:00
Jesse Duffield
117c0bd4f7 simplify code a bit 2021-07-31 17:33:13 +10:00
mjarkk
79848087bc Switch to github.com/gookit/color for terminal colors 2021-07-30 15:14:46 +02:00
Jesse Duffield
e73de332a1 refactor line by line panel 2021-04-18 16:55:09 +10:00
Jesse Duffield
7d62f103e4 big refactor to give our enums actual types 2021-04-02 11:00:15 +11:00
Jesse Duffield
7364525bf5 do not show commit files of another parent as added to the patch 2021-04-02 11:00:15 +11:00
Jesse Duffield
54910fdb76 refactor 2021-04-02 11:00:15 +11:00
Jesse Duffield
ade54b38c1 cleanup 2020-08-23 14:29:18 +10:00
Jesse Duffield
95a4ca6f8e remove todo comment 2020-08-23 14:29:18 +10:00
Jesse Duffield
43d891b8d6 support creating patches from files in diff mode 2020-08-23 14:29:18 +10:00
Jesse Duffield
30a555b108 don't needlessly load every file 2020-08-23 14:29:18 +10:00
Jesse Duffield
12bf851c7d faster patch manager 2020-08-23 14:29:18 +10:00
Jesse Duffield
59f5f5c1af refactor 2020-08-23 14:29:18 +10:00
Jesse Duffield
e6a1bd6566 generalise patch building stuff 2020-08-23 14:29:18 +10:00
Jesse Duffield
826d1660c9 move patch stuff into its own package 2020-08-15 11:41:37 +10:00