1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2026-06-20 01:19:23 +02:00
Commit Graph

7462 Commits

Author SHA1 Message Date
Stefan Haller b4dae453af Extract helper method removeFiles 2026-03-30 17:50:28 +02:00
Stefan Haller 46d8437bc2 Change test setup to allow nested directories 2026-03-30 17:50:28 +02:00
Stefan Haller dd7a3fad99 Don't stage out-of-date submodules when asking user to auto-stage after resolving conflicts (#5440)
When you rebase a branch and there are conflicts, lazygit asks you to
continue the rebase when it detects that all conflicts have been
resolved. However, it is common to make additional changes beyond just
fixing the conflicts (e.g. to fix build failures), and when doing that
while the "Continue the rebase?" prompt is showing, lazygit detects that
too and asks you if you want to stage those newly modified files too.
This is all well and good (and can be disabled for those who don't like
it); however, lazygit would treat out-of-date submodules as unstaged
changes and would offer to stage those as well, and this is pretty bad
and almost never what you want. Fix this by excluding submodules from
that second check.
2026-03-30 17:50:02 +02:00
Stefan Haller 9f38d02a4e Don't stage out-of-date submodules when asking user to auto-stage after resolving conflicts
When you rebase a branch and there are conflicts, lazygit asks you to continue
the rebase when it detects that all conflicts have been resolved. However, it is
common to make additional changes beyond just fixing the conflicts (e.g. to fix
build failures), and when doing that while the "Continue the rebase?" prompt is
showing, lazygit detects that too and asks you if you want to stage those newly
modified files too. This is all well and good (and can be disabled for those who
don't like it); however, lazygit would treat out-of-date submodules as unstaged
changes and would offer to stage those as well, and this is pretty bad and
almost never what you want. Fix this by excluding submodules from that second
check.
2026-03-30 17:41:53 +02:00
Stefan Haller 58bcfc4347 Add test to demonstrate the problem 2026-03-30 17:34:18 +02:00
Stefan Haller 4c4c3cd05d Bump github.com/buger/jsonparser from 1.1.1 to 1.1.2 (#5423)
Bumps [github.com/buger/jsonparser](https://github.com/buger/jsonparser)
from 1.1.1 to 1.1.2.
2026-03-30 14:22:40 +02:00
dependabot[bot] 3b9177c919 Bump github.com/buger/jsonparser from 1.1.1 to 1.1.2
Bumps [github.com/buger/jsonparser](https://github.com/buger/jsonparser) from 1.1.1 to 1.1.2.
- [Release notes](https://github.com/buger/jsonparser/releases)
- [Commits](https://github.com/buger/jsonparser/compare/v1.1.1...v1.1.2)

---
updated-dependencies:
- dependency-name: github.com/buger/jsonparser
  dependency-version: 1.1.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-30 14:19:07 +02:00
Stefan Haller e245b81425 Fix patch commands when git config has color=always (#5405)
This is the same option as used by
pkg.commands.git_commands.diff.GetDiff().

This fixes some operations patch operation (tested with moving patch to
another commit) with `git config set --global color.ui always` (or
`color.diff always`).
2026-03-30 10:44:42 +02:00
Matthijs Kooijman 590d6f2f80 Fix patch commands when git config has color=always
This is the same option as used by pkg.commands.git_commands.diff.GetDiff().
2026-03-30 10:42:26 +02:00
Stefan Haller afcfc61113 Fix grammar in the contributor guide (#5392)
Fix a small grammar issue in CONTRIBUTING.md by changing "need
documentation" to "needs documentation".
2026-03-30 10:14:08 +02:00
rohan436 81ba244863 docs: fix CONTRIBUTING grammar 2026-03-30 10:11:56 +02:00
Stefan Haller 7c66f633d6 Update redo keybinding in README.md (#5387)
The README says that this keybinding is ctrl+z, but the default
keybinding is shift+z — looks like this was changed in
376ca65807.

This PR updates the shortcut in the README to match the current
keybinding.
2026-03-30 10:11:05 +02:00
John Yeates 7a3bae4de1 Update redo keyboard shortcut in README.md
The README says that this shortcut is ctrl+z, but the default keymap is shift+z — looks like this was changed in 376ca65807.
2026-03-30 10:08:30 +02:00
Stefan Haller fc20702d3f Make Debian/Ubuntu install command architecture-independent (#5386) 2026-03-30 10:08:14 +02:00
Miika Tuominen 8fa1209ac8 Make Debian/Ubuntu install command architecture-independent 2026-03-30 10:05:58 +02:00
Stefan Haller ca946c5fcc Scroll to top when showing subcommits (#5425)
Previously, when showing subcommits of a branch or tag, scrolling down,
and then going out and entering subcommits again, it would select the
first commit but keep the previous scroll position, so that the
selection was not visible.
2026-03-27 14:57:50 +01:00
Stefan Haller 781105c49b Scroll to top when showing subcommits
Previously, when showing subcommits of a branch or tag, scrolling down, and then
going out and entering subcommits again, it would select the first commit but
keep the previous scroll position, so that the selection was not visible. Always
scroll to the top to fix this.
2026-03-27 14:55:02 +01:00
Stefan Haller 557ba51148 Improve performance of discarding many files (#5407)
When selecting a directory containing many changed files, or when
range-selecting many changed files, and then discarding them, this could
be so slow that lazygit appeared to hang; especially since there was no
UI feedback (e.g. a spinning status message).

This PR improves the performance greatly by batching the individual git
calls into a single one if possible. It still doesn't add UI feedback
though, hoping that the operation is now fast enough that it isn't
needed.

While we're at it, we fix a bug that would cause "Discard unstaged
changes" to discard more than just the visible files when filtering by
path.

Fixes #4581.
2026-03-27 14:40:30 +01:00
Stefan Haller 4d46f5af94 Improve performance for discarding range selection of many files
This is probably the less severe case, but it could still be an issue for people
who have many modified top-level files they want to discard, and have
showRootItemInFileTree set to false; they could select all those files by
pressing 'v' and '>'.
2026-03-27 14:34:47 +01:00
Stefan Haller ad31400818 Improve performance of discarding changes in large directories
Previously it would iterate over all changed files and call git checkout or git
reset for each one, which can take forever if there are hundreds or thousands of
files. Now it batches these into a single command if possible (taking care of
still passing the individual path names to the git call rather than just the
directory, which is necessary for making it work correctly when filtering --
this was actually broken for the "Discard unstaged changes" command, which is
fixed here).
2026-03-27 14:34:47 +01:00
Stefan Haller e434f5b5e9 Add runGitCmdOnPaths utility
Useful when we need to call git with potentially tons of arguments that might
exceed the OS' command-line length limit.
2026-03-27 14:34:47 +01:00
Stefan Haller f987b35a9e Add integration tests for discarding dir changes when filtering by path
When discarding a directory, we only want to discard those files that are
visible in the current filter view. The tests show that this already works
correctly for discarding all changes, but it doesn't for discarding only
unstaged changes: in this case, untracked files are handled correctly, but
changes to tracked files are discarded without respecting the filter.
2026-03-27 14:34:47 +01:00
Stefan Haller 5b829a6721 Add unit tests for WorkingTreeDiscard{All,Unstaged}DirChanges
We have integration tests for this functionality, but those only test the
behavior, not the performance. In these unit tests you can see that we make
individual calls to git checkout and git reset for each file, which is very slow
when there are lots of files.
2026-03-27 14:34:47 +01:00
Stefan Haller 4aa455e4eb Cleanup: better check for which files are removed
Previously it would only check that *if* removeFile was called, the passed
argument was the expected one; but it didn't check whether it was called at all.
Improve this by recording the file names that are removed, and checking them at
the end of each scenario.

This is going to be even more important for the tests that we are about to add
in the next commit, because for those there can be several calls to removeFile
in a single scenario.
2026-03-27 14:34:47 +01:00
Stefan Haller 4a8ab6f64e Cleanup: simplify by using lo.FilterMap instead of separate calls to Filter and Map 2026-03-27 14:34:47 +01:00
Stefan Haller 706a6c0474 Cleanup: use oscommands.RemoveFile rather than plain os.Remove
This makes it mockable for tests, and is consistent with other uses in this
file.
2026-03-27 14:34:47 +01:00
Stefan Haller d241ec4ee1 Fix searching commits or main view after switching repos (#5424)
When switching to a different repo, and then back to the original one,
searching would no longer work. The reason is that our contexts set
callbacks on their views; when switching to a different repo we
instantiate a new set of contexts, so they will overwrite the views'
callbacks with their new ones, but when switching back to the original
repo, we reuse the old contexts because they are still in memory, but
they won't set their callbacks again since they only do this on
construction.

To fix this, replace the view-local callbacks with a global one on the
gui that takes the view as an argument, so that the callback can look up
the associated context dynamically.
2026-03-27 14:30:31 +01:00
Stefan Haller 3eb5841b83 Fix searching commits or main view after switching repos
When switching to a different repo, and then back to the original one, searching
would no longer work. The reason is that our contexts set callbacks on their
views; when switching to a different repo we instantiate a new set of contexts,
so they will overwrite the views' callbacks with their new ones, but when
switching back to the original repo, we reuse the old contexts because they are
still in memory, but they won't set their callbacks again since they only do
this on construction.

To fix this, replace the view-local callbacks with a global one on the gui that
takes the view as an argument, so that the callback can look up the associated
context dynamically.
2026-03-27 14:26:20 +01:00
Stefan Haller 587a8bbf4f Remove go-git dependency (#5420)
Remove our dependency on go-git, which was including a ton of
third-party code for very little benefit.

In addition, this fixes the problem that lazygit wouldn't show any
branches or remotes for certain types of malformatted .git/config files,
e.g. when there's a config section like `[branch ""]`, `[remote ""]`, or
`[-remote "xyz"]`; see #3901 and #5112.
2026-03-27 14:13:03 +01:00
Stefan Haller 9d6064408c Remove go-git dependency 2026-03-27 14:08:08 +01:00
Stefan Haller a930f74397 Remove go-git repo from GitCommon
It is no longer used now.
2026-03-27 14:08:07 +01:00
Stefan Haller 6f9d234116 Remove go-git repo from ConfigCommands 2026-03-27 14:08:07 +01:00
Stefan Haller 1da87b9a7c Don't use go-git to parse branches
As with the previous commit, the code to parse `git config --get-regex` output
on our end isn't so bad.
2026-03-27 14:04:51 +01:00
Stefan Haller 23f973496f Don't use go-git to parse remotes
It only takes a few lines of code to parse remotes on our end from the output of
`git config --get-regexp`.
2026-03-27 14:00:58 +01:00
Stefan Haller d864edb0c3 Add support for clicking on arrows in the file list to expand/collapse directories (#5365)
### PR Description
This PR adds support for clicking on arrows in the file changes list
view, so that a mouse can be used to expand/collapse directories. This
enhancement was raised here as issue #5088.
2026-03-25 20:58:49 +01:00
blakemckeany ee3bb06b2a Add support for clicking on arrows in the file list to expand/collapse directories
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2026-03-25 17:08:35 +01:00
blakemckeany 4567840198 Add GetOnClick to HasKeybindings
Can be used for doing additional click handling in list views.

Like the GetOnDoubleClick hook we should try to find a better design for this
than putting it in HasKeybindings and BaseContext, since it is only used by list
contexts.

Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2026-03-25 17:08:02 +01:00
blakemckeany 61b72cef38 Add GetVisualDepth method to FileTree/CommitFileTree 2026-03-25 16:41:12 +01:00
Stefan Haller fe5df2334b Document some of the methods of HasKeybindings
We have some documentation for the corresponding setters in IBaseContext, but
that's part of the controller infrastructure and not client facing. For somebody
implementing a new view, this is where they will probably look for what methods
they can override.
2026-03-25 16:41:10 +01:00
Stefan Haller 72bff90822 Rename GetOnClick (et al) to GetOnDoubleClick
When this was originally introduced, it handled single clicks on a list entry
(treating them similar to a double-click by checking whether the click was on
the selected entry). Arguably it should have been called OnDoubleClick back then
already; but when we later changed it to do actual double-click detection (see
37197b8e9a), we should have renamed the methods.
2026-03-25 14:58:53 +01:00
Stefan Haller dcfdf4084e Fix the expanded layout of the branches panel (half and full screen modes) (#5413)
If the showDivergenceFromBaseBranch config is not none, the expanded
branches panel would no longer show the remote branch and subject; the
reason was that we padded the name all the way to the right edge of the
view so that the divergence information is right-aligned.

To fix this, we simply don't right-align the divergence in half or full
screen mode. This is a bit unfortunate, but it's hard to do any better,
because we don't know the width of our column in advance. One thing I
tried is to make the divergence a separate column in that case (with an
explicit right-alignment set on it via getColumnAlignments; however,
this makes it harder to properly truncate the name when the window is
too narrow.
2026-03-23 17:31:10 +01:00
Stefan Haller d9487bf31c Fix the expanded layout of the branches panel (half and full screen modes)
If the showDivergenceFromBaseBranch config is not none, the expanded branches
panel would no longer show the remote branch and subject; the reason was that we
padded the name all the way to the right edge of the view so that the divergence
information is right-aligned.

To fix this, we simply don't right-align the divergence in half or full screen
mode. This is a bit unfortunate, but it's hard to do any better, because we
don't know the width of our column in advance. One thing I tried is to make the
divergence a separate column in that case (with an explicit right-alignment set
on it via getColumnAlignments; however, this makes it harder to properly
truncate the name when the window is too narrow.
2026-03-23 17:25:41 +01:00
Stefan Haller 24158aa6d0 Add a note about AI to CONTRIBUTING.md (#5404) 2026-03-23 14:22:19 +01:00
Stefan Haller 0093059949 Add a note about AI to CONTRIBUTING.md 2026-03-22 11:30:22 +01:00
Stefan Haller ec7d6b479a Fix staging only some lines of a block of consecutive changes (#5396)
Given a block of consecutive changed lines, staging only some of those
changes didn't always work. Consider the following scenario:
```diff
@@ -1,5 +1,5 @@
 a
-b
-c
-d
+b'
+c'
+d'
 e
```
Trying to stage only the change to "d" worked already as expected, but
staging either "b" or "c" didn't; the order of the deleted and added
lines in staged changes were wrong. We don't solve the "c" case in this
PR, as it's probably uncommon enough so that it doesn't matter too much,
and it seems to be quite a bit harder than the other two (and git gui
doesn't support it either, for the record). But we fix the "b" case
here, which is probably the most common one.

Fixes #5103.
2026-03-20 08:23:19 +01:00
Stefan Haller e1e042fb66 Revert test workaround
Now that the bug with selecting the next stageable line is fixed, we can go back
to the original, simpler way of expressing the test.
2026-03-19 16:57:53 +01:00
Stefan Haller 6bfcab3d89 Fix selection after staging an added line
In some cases, staging an added line could result in the previous deleted line
to become selected, rather than the next added line.
2026-03-19 16:57:53 +01:00
Stefan Haller 8fbc70bf84 Fix staging only some lines of a block of consecutive changes
This fixes the problem; a consequence of this change is that given the following
scenario:

@@ -1,3 +1,3 @@
 1
-2
+2b
 3

staging only the line `+2b` will put it *before* the unchanged `2` line, rather
than after it as you might expect (the changed unit tests demonstrate this).
Since this should be a pretty uncommon scenario, I guess it is an ok compromise.

As you can see in the changed tests, while the behavior of what gets staged is
fixed now, it doesn't always correctly select the next line to stage. We'll
address this in the next commit.
2026-03-19 16:57:53 +01:00
Stefan Haller b8ed4faf9b Add test for how the selection advances after staging lines
This is currently working correctly, but will break with the next commit; we'll
fix this again afterwards.
2026-03-19 16:44:55 +01:00
Stefan Haller 7929519ccf Add regression test for staging a single added line
This is a pretty special case (see comment in the test for details). It is
working correctly, but I almost broke it during development, so it's good to
cover it with a test.
2026-03-19 16:44:55 +01:00