Commit Graph
100 Commits
Author SHA1 Message Date
Stefan HallerandGitHub 0c0f53fa31 Allow filtering the keybindings menu by keybinding (#4821)
- **PR Description**

When filtering the keybindings menu using `/`, typing `@` filters by
keybinding.

Closes #4739.
2025-08-14 15:04:56 +02:00
Stefan Haller a08799ac15 Allow filterable contexts to customize the filter label 2025-08-14 15:02:48 +02:00
Stefan Haller 2ed11336b5 Allow filtering for keybindings by prepending filter string with '@' 2025-08-14 15:02:48 +02:00
Stefan Haller d52d5e6a9e Allow filtered lists to preprocess the filter string
An example for this can be seen in the next commit.

We make this a setter rather than an added constructor argument so that we don't
have to change all those contexts that don't want to make use of this.
2025-08-14 15:02:48 +02:00
Stefan Haller f1c07b3aed Strengthen text expectation
This assertion didn't test anything useful, given that the filtered view already
has two lines. This should have been adapted in 9f0b4d0000 when we added
section headers while filtering.
2025-08-14 15:02:48 +02:00
Stefan HallerandGitHub 389ff29871 Fix right-alignment of divergence from base branch for branch checked out in a worktree (#4824)
- **PR Description**

We didn't take the worktree icon into account properly, so the
divergence indication was offset to the left by two characters in this
case.

I haven't used worktrees myself so far, so I didn't notice this before.
2025-08-14 14:30:51 +02:00
Stefan Haller e54a8b2ee7 Fix right-alignment of divergence from base branch for branch checked out in a worktree
We didn't take the worktree icon into account properly, so the divergence
indication was offset to the left by two characters in this case.
2025-08-14 14:28:11 +02:00
Stefan HallerandGitHub 1e75aee37e Add installation with gah (#4820)
- **PR Description**

This PR adds to the documentation a way of installation using
[gah](https://github.com/marverix/gah/).

> gah is an GitHub Releases app installer, that does not require sudo.
It is a simple bash script that downloads the latest release of an app
from GitHub and installs it in `~/.local/bin`. It is designed to be used
with apps that are distributed as a single binary file.
2025-08-13 18:30:47 +02:00
Stefan HallerandGitHub 28ef4a13d2 Pass only Git-tracked Go files to gofumpt (#4809)
## **PR Description**
The below error message is shown when executing `make format` when
`test/_results/demo/worktree_create_from_branches/actual/repo/src/shims.go`
exists (maybe executing integration test produces this file?).

```sh
$ make format
gofumpt -l -w .
test/_results/demo/worktree_create_from_branches/actual/repo/src/shims.go:1:20: expected 'package', found 'EOF'
make: *** [format] Error 2
```

I have confirmed it works without above error when I run `make format`
on this PR's branch.
2025-08-12 11:46:02 +02:00
Stefan HallerandGitHub b1382da9ec Fix delay with flicking through files or commits when git diff is very slow (#4803)
One reason why git diff can be very slow is when "diff.algorithm =
histogram" is being used. In this case, showing a very long single-file
diff can take seconds to load, and you'll see the "loading..." message
in the main view until we got the first lines of the diff to show.
There's nothing really we can do about this delay; however, when
switching to another, shorter file (or commit) while the "loading..."
message is still showing, this switch should be instantaneous. And it
was before 0.54.0, but we broke this in 0.54.0 with 8d7740a5ac
(#4782); now users have to wait for the slow git diff command to output
more text before the switch occurs. To fix this, don't block waiting for
the process to terminate if we just stopped it.

In addition, improve CPU usage by terminating git processes gracefully
(by sending them a TERM signal); this helps keep CPU usage low when
flicking through several of these huge diffs with "diff.algorithm =
histogram", because it avoids having several git processes running in
the background, calculating expensive diffs that we are never going to
show. Unfortunately this is only possible on Linux and Mac, so Windows
users will have to live with the higher CPU usage. The recommended
workaround is to not use "diff.algorithm = histogram".

Fixes #4798.
2025-08-11 18:13:42 +02:00
Stefan Haller e056e33da5 Improve CPU usage when flicking through large diffs
The previous commit already fixed the user-visible lag, but there's still a
problem with multiple background git processes consuming resources calculating
diffs that we are never going to show. Improve this by terminating those
processes (by sending them a TERM signal).

Unfortunately this is only possible on Linux and Mac, so Windows users will have
to live with the higher CPU usage. The recommended workaround is to not use
"diff.algorithm = histogram".
2025-08-11 18:07:21 +02:00
Stefan Haller 898f565116 Fix delay with flicking through files or commits when git diff is very slow
One reason why git diff can be very slow is when "diff.algorithm = histogram" is
being used. In this case, showing a very long single-file diff can take seconds
to load, and you'll see the "loading..." message in the main view until we got
the first lines of the diff to show. There's nothing really we can do about this
delay; however, when switching to another, shorter file (or commit) while the
"loading..." message is still showing, this switch should be instantaneous. And
it was before 0.54.0, but we broke this in 0.54.0 with 8d7740a5ac (#4782); now
users have to wait for the slow git diff command to output more text before the
switch occurs.

To fix this, don't block waiting for the process to terminate if we just stopped
it.
2025-08-11 18:07:21 +02:00
Stefan Haller e5acbed848 Cleanup: move UpdateWindowTitle to platform-specific source files
No need to do a runtime check if we already have the platform-specific files.
2025-08-11 18:07:21 +02:00
Stefan HallerandGitHub 77a9207f9e Update the badges of golangci-lint and homebrew in README.md (#4807) 2025-08-11 13:56:20 +02:00
Stefan Haller 985013718d Change color of github tag and homebrew badges to blue
Both of these badges have the coloring logic to show stable releases in blue,
and prereleases in orange. The criterion for a prerelease is that the major
version is 0. Now it is debatable whether we consider lazygit "stable", but I
don't feel we are in a preliminary state of the project, working towards the
first final 1.0 release, so I feel blue expresses the state of the project
better.
2025-08-11 13:42:19 +02:00
Stefan Haller 39b4f16e1a Update github tag badge
It doesn't really seem to make a difference, but this is what I get from
shields.io's builder (no idea where the previous .svg extension came from).
2025-08-11 13:37:53 +02:00
Stefan Haller 2864eecd37 Update homebrew link
The old link was broken, it would have to be "Formula/l/lazygit.rb" instead of
"Formula/lazygit.rb".

However, I don't find it very useful to link to the raw formula file, so I
decided to change the link to point to the homebrew web page for lazygit.
2025-08-11 13:36:05 +02:00
Stefan HallerandGitHub 0da27604e4 Update CONTRIBUTING.md to clarify translation contribution process (#4806) 2025-08-10 10:01:43 +02:00
Stefan HallerandGitHub 26db25be34 Fix scrollbar in certain popup panels (e.g. the intro message for new users) (#4804)
When showing a confirmation whose text ends with a line feed, we would
make the popup panel one line less tall than it needs to be, so it would
show a scroll bar. One example where this occurred is the very first
popup that users ever see (the "seriously you rock" message for new
users); that's a pretty bad first impression.

This happens because our code to suppress trailing newlines in views
doesn't work for styled text, and the text in confirmations is bold.
This code checks if the last character of the text is a line feed, and
in this case it isn't; the escape sequence for turning bold off comes
after it.

We should really fix this by improving that mechanism, but this would
require some tricky logic, so as a quick fix, trim trailing (and
leading) linefeeds from the text that we display in a confirmation,
before making it bold.
2025-08-09 11:52:04 +02:00
Stefan Haller 09e2bfaf99 Trim trailing newlines when showing confirmations
When showing a confirmation whose text ended with a line feed, we would make the
popup panel one line less tall than it needs to be, so it would show a scroll
bar. One example where this occurred is the very first popup that users ever see
(the "seriously you rock" message for new users); that's a pretty bad first
impression.

This happens because our code to suppress trailing newlines in views doesn't
work for styled text, and the text in confirmations is bold. This code checks if
the last character of the text is a line feed, and in this case it isn't; the
escape sequence for turning bold off comes after it.

We should really fix this by improving that mechanism, but this would require
some tricky logic, so as a quick fix, trim trailing (and leading) linefeeds from
the text that we display in a confirmation, before making it bold.
2025-08-08 20:37:44 +02:00
Stefan Haller a364ee53a8 Cleanup: remove duplicate test case
This is identical to the one right before.
2025-08-08 11:24:43 +02:00
Stefan HallerandGitHub c0dcf7d0ad Fix the useHunkModeInStagingView hint in the breaking changes message (#4800)
`useHunkSelectionMode` must have been a left-over from an earlier
iteration of the branch where the config had a different name.
2025-08-06 19:31:18 +02:00
Stefan Haller d869c23c1a Fix the useHunkModeInStagingView hint in the breaking changes message 2025-08-06 19:26:00 +02:00
Stefan HallerandGitHub 0262a8de69 Stop bumping our homebrew formula (#4799)
It is being auto-bumped by homebrew, like most formulae these days, so
no reason for us to do that explicitly; and it actually fails with an
error message, so stop trying.
2025-08-06 19:24:46 +02:00
Stefan Haller 04c2be826b Stop bumping our homebrew formula
It is being auto-bumped by homebrew, like most formulae these days, so no reason
for us to do that explicitly; and it actually fails with an error message, so
stop trying.
2025-08-06 14:02:23 +02:00
Stefan HallerandGitHub c08903e3ad Stop updating Jesse's homebrew tap (#4797)
The tap is being retired, see
https://github.com/jesseduffield/homebrew-lazygit/pull/3.
2025-08-06 13:30:43 +02:00
Stefan Haller 5a654b1d56 Stop updating Jesse's homebrew tap
The tap is being retired, see
https://github.com/jesseduffield/homebrew-lazygit/pull/3.
2025-08-06 13:28:07 +02:00
Stefan HallerandGitHub 525edfbc4d Fix temp dir permission problem on multi-user machines (#4796)
In 3a9dbf7341 we created a global /tmp/lazygit/ folder that contains
the temp directories of each running instance, to avoid polluting /tmp
with multiple folders. The problem with that approach was that the
folder was created with 700 permissions, so if multiple users were using
lazygit on the same machine (e.g. a server), all users except the first
one would get fatal errors on startup.

Fix this by creating temp folders containing the user's uid.

Fixes #4793.
2025-08-06 09:48:14 +02:00
Stefan Haller 71813fdda5 Create a user-specific temp dir to avoid permission problems on multi-user machines
In 3a9dbf7341 we created a global /tmp/lazygit/ folder that contains the temp
directories of each running instance, to avoid polluting /tmp with multiple
folders. The problem with that approach was that the folder was created with 700
permissions, so if multiple users were using lazygit on the same machine (e.g. a
server), all users except the first one would get fatal errors on startup.

Fix this by creating temp folders containing the user's uid.
2025-08-05 22:50:22 +02:00
Stefan HallerandGitHub bcb95bd211 Update Fedora section of the README.md file (#4792)
After discussion from the following PR (
https://github.com/jesseduffield/lazygit/pull/4362 ) I have finally
found time to make a PR to update the Fedora section of the README.md
file. I actually use those instructions myself from few different Fedora
and Amazon Linux 2023 machines.

Here is an example of installing lazygit from the Copr:

```
» sudo dnf install lazygit
Updating and loading repositories:
Repositories loaded.
Package                                                              Arch        Version                                                              Repository                                                  Size
Installing:
 lazygit                                                             x86_64      0.48.0-1.fc41                                                        copr:copr.fedorainfracloud.org:dejan:lazygit            21.5 MiB

Transaction Summary:
 Installing:         1 package

Total size of inbound packages is 6 MiB. Need to download 6 MiB.
After this operation, 22 MiB extra will be used (install 22 MiB, remove 0 B).
Is this ok [y/N]: y
[1/1] lazygit-0:0.48.0-1.fc41.x86_64                                                                                                                                          100% |   3.7 MiB/s |   5.7 MiB |  00m02s
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[1/1] Total                                                                                                                                                                   100% |   3.7 MiB/s |   5.7 MiB |  00m02s
Running transaction
[1/3] Verify package files                                                                                                                                                    100% |  52.0   B/s |   1.0   B |  00m00s
[2/3] Prepare transaction                                                                                                                                                     100% |   3.0   B/s |   1.0   B |  00m00s
[3/3] Installing lazygit-0:0.48.0-1.fc41.x86_64                                                                                                                               100% |  44.9 MiB/s |  21.5 MiB |  00m00s
Complete!
```
2025-08-05 12:39:03 +02:00
Stefan HallerandGitHub 5175798cb1 README.md: Update Sponsors (#4710)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action
2025-08-02 10:34:01 +02:00
Stefan HallerandGitHub e732833d7d Update translations from Crowdin (#4791) 2025-08-01 11:10:01 +02:00
Stefan Haller 8bf58f9a6b Update translations from Crowdin 2025-08-01 11:07:35 +02:00
Stefan HallerandGitHub 3541b090af Enable hunk staging mode by default (#4780)
- **PR Description**

In #4684 we improved the hunk selection behavior to work on blocks of
changes instead of actual hunks, and I find this so useful that I wanted
to use it by default. In #4685 I added a user config to make hunk
selection the default, but I made it an opt-in config because I was
worried that users might not find out how to switch back to line
selection if needed.

To address this concern, in this PR I add a popup that explains this the
first time the user enters staging; there is also a breaking changes
notice at startup, and we improve the options display at the bottom of
the screen to be clearer about this. Hopefully these measures are enough
to not confuse people.

Closes #4759.
2025-08-01 10:38:06 +02:00
Stefan Haller c216388b5c Add breaking changes notice about hunk mode being the default now 2025-08-01 10:35:17 +02:00
Stefan Haller 117bb3f829 Cleanup: whitespace 2025-08-01 10:35:17 +02:00
Stefan Haller 3d703bc9b9 Show hint about hunk staging mode being the default now, and how to switch to line mode
It is shown the first time the user enters either staging or patch building.
2025-08-01 10:35:17 +02:00
Stefan Haller 37724e9d14 Cleanup: rely on zero values for initialization 2025-08-01 10:35:17 +02:00
Stefan Haller 4d51234ee2 Enable hunk staging mode by default 2025-08-01 10:35:16 +02:00
Stefan Haller eb41bd2af2 Change the "toggle hunk selection" binding description to be dynamic
When the useHunkModeInStagingView config is on and you enter the staging view
with hunk selection enabled, it is confusing to see "a: Select hunk" in the
options view at the bottom.
2025-08-01 10:35:16 +02:00
Stefan Haller 75afa099e9 Add support for dynamic binding descriptions 2025-08-01 10:35:16 +02:00
Stefan Haller 9eb1e3a729 Add a GetShortDescription() method to Binding 2025-08-01 10:35:16 +02:00
Stefan Haller d0438b7d33 Cleanup: better receiver name
No need for this to be uppercase.
2025-08-01 10:35:16 +02:00
Stefan HallerandGitHub 98801da106 Terminate git processes more gracefully to avoid the stale index.lock problem (#4782)
- **PR Description**

Instead of killing git processes when we no longer need them, close
their ptys or output pipes; this makes them terminate more gracefully,
and it avoids the problem of left-over index.lock files that the next
git command chokes on.

To fix the index.lock problem, only the first two commits of the branch
are needed. I decided to go a bit further and add more commits to make
similar changes to other places in the code; these might be considered
more risky than necessary, and we might decide to drop or revert them if
they cause problems. But it does allow us to remove the kill package
dependency altogether.

Fixes #2050.
2025-08-01 10:35:03 +02:00
Stefan Haller 1a72561b15 Remove the kill package dependency 2025-08-01 10:32:47 +02:00
Stefan Haller 7d9eaead54 Close the pty instead of killing the process for runAndDetectCredentialRequest
As with the previous commit, this is not strictly necessary for anything, just
cleaner.
2025-08-01 10:32:47 +02:00
Stefan Haller 83046a05d4 Don't kill processes in RunAndProcessLines
As we just did for tasks, close their stdout pipe instead. This makes the called
process terminate more gracefully.

This isn't a change that we *need* to make, it's just a bit nicer.
2025-08-01 10:32:47 +02:00
Stefan Haller 8d7740a5ac Don't kill tasks when we no longer need them
Now that we close a task's stdout pipe when we are done with it, it should
terminate by itself at that point, so there's no longer a need to kill it. This
way, called processes get a chance to terminate gracefully rather than being
killed with SIGKILL; in particular, this allows git to clean up its index.lock
file if it created one.
2025-08-01 10:32:46 +02:00
Stefan Haller d0a10bafbd Close a task's stdout pipe when we are done with it
This is similar to what we do when running tasks in a pty (we close the pty
there), and it should cause the called command to terminate.
2025-08-01 10:32:46 +02:00
Stefan HallerandGitHub 47afa7eb95 Improve temp dir handling (#4784)
- Lazygit creates a temp dir at startup, and is supposed to clean it up
after itself; however, this only worked for the main executable, not
when lazygit was spawned as a helper daemon for interactive rebases, so
we would leak a temp dir every time the user pressed `e` or `ctrl-j` or
other similar commands.
- All these temp dirs were created at top level in `/tmp` and thus
pollute it; now we create them inside a `/tmp/lazygit/` folder. This is
no longer quite as important now that the first bug is fixed, but might
still be useful when lazygit crashes, or when running many instances at
once in different terminal tabs.

Resolves #4781.
2025-08-01 10:32:32 +02:00
Stefan Haller 3a9dbf7341 Create temp directories inside a "lazygit" folder rather than top-level in /tmp
This is no longer as important now that we fixed the stale, left-over temp dirs
caused by daemon mode, but it could still be helpful in case lazygit crashes, or
if you have many instances of lazygit running.
2025-08-01 10:30:28 +02:00
Stefan Haller 6a17144ef4 Don't exit after handling daemon mode
The function that called us has just created a temp dir, and scheduled a defer
to remove it again; by calling os.Exit we short-cut this defer, and don't clean
up the temp dir. There is no reason to exit here, the calling function will
return after having called us.
2025-08-01 10:30:28 +02:00
Stefan Haller f4afeed9ff Improve .gitignoring debug executables 2025-08-01 10:30:28 +02:00
Stefan HallerandGitHub 05c30b8344 Fix commit hash colors when filtering by path or aythor (#4789)
- **PR Description**

Previously we would call git merge-base with the upstream branch to
determine where unpushed commits end and pushed commits start, and also
git merge-base with the main branch(es) to see where the merged commits
start. This worked ok in normal cases, but it had two problems:
- when filtering by path or by author, those merge-base commits would
usually not be part of the commit list, so we would miss the point where
we should switch from unpushed to pushed, or from pushed to merged. The
consequence was that in filtering mode, all commit hashes were always
yellow.
- when main was merged into a feature branch, we would color all commits
from that merge on down in green, even ones that are only part of the
feature branch but not main. (See #3796)

To fix these problems, we switch our approach to one where we call git
rev-list with the branch in question, with negative refspecs for the
upstream branch and the main branches, respectively; this gives us the
complete picture of which commits are pushed/unpushed/merged, so it also
works in the cases described above.

And funnily, even though intuitively it feels more expensive, it
actually performs better than the merge-base calls (for normal usage
scenarios at least), so the commit-loading part of refresh is faster now
in general. We are talking about differences like 300ms before, 140ms
after, in some unscientific measurements I took (depends a lot on repo
sizes, branch length, etc.). An exception are degenerate cases like
feature branches with hundreds of thousands of commits, which are slower
now; but I don't think we need to worry about those too much.

Fixes #3796.
2025-08-01 10:29:16 +02:00
Stefan Haller e46dc1ead6 Use a better approach for determining pushed and merge statuses
Previously we would call git merge-base with the upstream branch to determine
where unpushed commits end and pushed commits start, and also git merge-base
with the main branch(es) to see where the merged commits start. This worked ok
in normal cases, but it had two problems:
- when filtering by path or by author, those merge-base commits would usually
not be part of the commit list, so we would miss the point where we should
switch from unpushed to pushed, or from pushed to merged. The consequence was
that in filtering mode, all commit hashes were always yellow.
- when main was merged into a feature branch, we would color all commits from
that merge on down in green, even ones that are only part of the feature branch
but not main.

To fix these problems, we switch our approach to one where we call git rev-list
with the branch in question, with negative refspecs for the upstream branch and
the main branches, respectively; this gives us the complete picture of which
commits are pushed/unpushed/merged, so it also works in the cases described
above.

And funnily, even though intuitively it feels more expensive, it actually
performs better than the merge-base calls (for normal usage scenarios at least),
so the commit-loading part of refresh is faster now in general. We are talking
about differences like 300ms before, 140ms after, in some unscientific
measurements I took (depends a lot on repo sizes, branch length, etc.). An
exception are degenerate cases like feature branches with hundreds of thousands
of commits, which are slower now; but I don't think we need to worry about those
too much.
2025-07-31 15:50:53 +02:00
Stefan Haller 20517330b4 Change GetCommitsOptions.RefForPushedStatus to a models.Ref
This makes it easier to use the full ref in the git merge-base call, which
avoids ambiguities when there's a tag with the same name as the current branch.

This fixes a hash coloring bug in the local commits panel when there's a tag
with the same name as the checked out branch; in this case all commit hashes
that should be yellow were painted as red.
2025-07-31 15:26:19 +02:00
Stefan Haller 4b9921d0a4 Move the Ref interface from gui/types to models
This is a type that can be useful for model/backend stuff, so move it there. We
are going to use it in the API of the commit loader.
2025-07-31 15:21:34 +02:00
Stefan Haller cc0b5a2f7f Cleanup: remove the ignoringWarnings hack from GetMergeBase
GetMergeBase is always called with a full ref, so it shouldn't need the
ignoringWarnings hack (which is about ignoring warnings coming from ambiguous
refs).

Also, separate stdout and stderr, which would also have solved the problem. We
no longer really need it now, but it's still cleaner.
2025-07-31 15:21:34 +02:00
Stefan HallerandGitHub a02f1e8655 Draw divergence from base branch right-aligned in branches view (#4785)
- **PR Description**

I didn't enable the `showDivergenceFromBaseBranch` config by default yet
(even though I find it very useful) because I'm worried that people
might find the display too noisy. Drawing the divergence information
right-aligned helps reduce that noise a little bit.
2025-07-30 14:26:00 +02:00
Stefan Haller abb7bed0c4 Draw divergence from base branch right-aligned in branches view
Also, remove it from the status view. I'd say it isn't really needed there,
although I don't have a strong opinion about that.
2025-07-30 14:23:31 +02:00
Stefan HallerandGitHub d7626d4ccf refactor: use slices.Equal to simplify code (#4764)
- **PR Description**

In the Go 1.21 standard library, a new function has been introduced that
enhances code conciseness and readability. It can be find
[here](https://pkg.go.dev/slices@go1.21.1#Equal).
2025-07-29 11:23:17 +02:00
Stefan HallerandGitHub 8e04349828 When pressing a to stage all files, don't include untracked files when showing only tracked files (#4779)
- **PR Description**

This is very similar to what we did for pressing space in #4386; we
forgot that the "stage all" command has the same issue.

Also, fix two other commands that stage all files under the hood:
- when continuing a rebase after resolving conflicts, we auto-stage all
files, but in this case we never want to include untracked files,
regardless of the filter
- likewise, pressing ctrl-f to find a base commit for fixup stages all
files for convenience, but again, this should only stage files that are
already tracked
2025-07-28 18:01:56 +02:00
Stefan Haller 9c0e103b90 Stage only tracked files when staging all in filter-by-tracked-files view
Also, fix two other commands that stage all files under the hood:
- when continuing a rebase after resolving conflicts, we auto-stage all files,
  but in this case we never want to include untracked files, regardless of the
  filter
- likewise, pressing ctrl-f to find a base commit for fixup stages all files for
  convenience, but again, this should only stage files that are already tracked
2025-07-28 14:10:38 +02:00
Stefan Haller 8cc49e3be5 Add test demonstrating the problem
When filtering to show only tracked files, pressing `a` would also stage
untracked files, which is confusing and undesired.
2025-07-28 14:05:25 +02:00
Stefan HallerandGitHub 79da2ca3af Make the minimum required git version a placeholder in the error text (#4778)
- **PR Description**

This way we don't have to update the text and all translations every
time we bump the version.

Remove the year from the error text, it's cumbersome to update and I
don't find it very important to have in the message.

Also remove the invitation to file an issue; I don't find it very likely
that we are going to relax the minimum git requirement again.
2025-07-28 13:13:41 +02:00
Stefan Haller 05b27c390d Make the minimum required git version a placeholder in the error text
This way we don't have to update the text and all translations every time we
bump the version.

Remove the year from the error text, it's cumbersome to update and I don't find
it very important to have in the message.

Also remove the invitation to file an issue; I don't find it very likely that we
are going to relax the minimum git requirement again.
2025-07-28 13:10:25 +02:00
Stefan HallerandGitHub a52d953789 Fix performance regression on startup in repos with many tags (#4777)
- **PR Description**

In #4663 we added information in the tags panel about the selected tag
(whether it's annotated etc). Unfortunately this introduced a
performance regression in repositories with many tags, so revert this
and implement the feature in a slightly different way to avoid the
performance hit.

Fixes #4770.
2025-07-28 12:26:53 +02:00
Stefan Haller 1c533dcd55 Revert "Add IsAnnotated field to models.Tag struct"
It seems that `git for-each-ref` is a lot slower than `git tag --list` when
there are thousands of tags, so revert back to the previous method, now that we
no longer use the IsAnnotated field.

This reverts commit b12b1040c3.
2025-07-28 10:53:51 +02:00
Stefan Haller 151e80902e Use a different way to check if a tag is annotated
Storing it in the Tag struct makes loading tags a lot slower when there is a
very large number of tags; so determine it on the fly instead. On my machine,
the additional call takes under 5ms, so it seems we can afford it.
2025-07-28 10:53:51 +02:00
Stefan Haller 44159ff926 Add tests for tag information rendering
These should have been added when we started rendering this information in
e5b09f34e0; apparently I was too lazy back then. Adding them now to guard
against breaking it in the next commit.

I'm adding these to the CRUD tests, it doesn't seem worth adding separate tests
just for these assertions.
2025-07-28 10:53:51 +02:00
Stefan HallerandGitHub 8483239dad Fix index out of bounds panic when repository has massive tags (#4776)
- **PR Description**

Fixes an index out of bounds panic that occurs when lazygit starts up in
repositories with a large number of tags on a single commit.

When a commit has thousands of tags, the git log output can become
malformed or truncated, causing the `extractCommitFromLine` function to
receive fewer than the expected 8 null-separated fields. This results in
an index out of bounds panic when trying to access `split[5]` and
beyond.

Closes #4765
2025-07-28 10:53:23 +02:00
Stefan Haller 15f8ad31e0 Cleanup: use nil for empty slice 2025-07-27 18:51:03 +02:00
Stefan HallerandGitHub 26f2c0203b Allow rewording or dropping commits in filtering mode (#4756)
- **PR Description**

Rewording or dropping commits was disabled when filtering commits by
path or author. This used to be necessary a long time ago for technical
reasons, but these reasons went away with the merge of #2552, so enable
them now.

Technically we could enable a few more, but I chose not to because some
might be surprising or confusing in filtering mode. For example,
creating a fixup commit would work (shift-F), but the newly created
commit might not show up if it doesn't match the filter. Similarly,
pressing `f` to fixup a commit into its parent would work, but that
parent commit might not be visible, so users might expect to be fixing
up into the next visible commit.

Fixes #2554.
2025-07-27 12:50:24 +02:00
Stefan Haller 52be6964ed Allow rewording and dropping commits in filtering mode
There's no reason not to allow these.

Technically we could enable a few more, but I chose not to because some might be
surprising or confusing in filtering mode. For example, creating a fixup commit
would work (shift-F), but the newly created commit might not show up if it
doesn't match the filter. Similarly, pressing `f` to fixup a commit into its
parent would work, but that parent commit might not be visible, so users might
expect to be fixing up into the next visible commit.
2025-07-27 12:48:38 +02:00
Stefan Haller bc936e8d1b Extract helper function for integration test
We are going to reuse it in two other tests that we are going to add in the next
commit.
2025-07-27 12:48:38 +02:00
Stefan Haller 6976d38586 Inline the OutsideFilterMode guard into every binding
The reason for doing this is that we want to remove the guard from some of
these, but we don't want to change the order.
2025-07-27 12:48:38 +02:00
Stefan HallerandGitHub 96480edb01 Show [0] keybinding in main view title (#4754)
- **PR Description**

Show the `[0]` keybinding in the title of the main view, to make it more
discoverable.

Also, move it to the "global" section of the keybindings menu.

And several minor fixes and cleanups, see individual commits for
details.

Fixes #4738.
2025-07-27 12:29:50 +02:00
Stefan Haller 0cfe42b43f Show the key for focusing the main view ("[0]" by default) in the main view title prefix
We show it only if the "showPanelJumps" config is on, although the
focus-main-view command is not technically part of the panel jump keys; but it
looks similar.
2025-07-27 12:28:06 +02:00
Stefan Haller 72a8e8194d Fix display of panel jump keys for disabled bindings 2025-07-27 12:27:56 +02:00
Stefan Haller b9f4c43695 Allow focusing the main view for the status panel
I left this out originally because it's not needed for the status "dashboard"
view (except on really tiny screens); however, it *is* useful after pressing `a`
to show the all branches log, and even more so for people who use the
"statusPanelView: allBranchesLog" config. And it doesn't really hurt for the
dashboard view either, so just enable it always rather than making a distinction
which view we are showing.
2025-07-27 12:27:35 +02:00
Stefan Haller 837efd95e2 Move the "Focus main view" command to the global section of the keybindings menu 2025-07-27 12:25:16 +02:00
Stefan Haller 96a6e659a6 Make LabelFromKey return an empty string for unset keys
It previously returned "\x00", which is probably not intended, but happened to
work.
2025-07-27 12:25:16 +02:00
Stefan Haller 7fe96e9aee Include commands without keybinding in options menu
This is not a behavior change, we already include these in the menu, but that's
because of a bug that we will fix in the next commit.

I find it useful to see these commands, especially for rarely-used custom
commands that you don't want to waste a keybinding on.
2025-07-27 12:25:16 +02:00
Stefan HallerandGitHub 2bd6881f60 Don't use hunk mode for added or deleted files even when useHunkModeInStagingView config is on (#4758)
- **PR Description**

When entering staging (or patch building) for an added or deleted file,
it doesn't make sense to use hunk mode, because pressing space would
stage/unstage the entire file, and if the user wanted to do that, they
would have pressed space in the Files panel. So always use line mode for
added/deleted files by default, even if the useHunkModeInStagingView
user config is on.
2025-07-27 12:23:45 +02:00
Stefan Haller c5acad777d Don't use hunk mode for added or deleted files
When entering staging (or patch building) for an added or deleted file, it
doesn't make sense to use hunk mode, because pressing space would stage/unstage
the entire file, and if the user wanted to do that, they would have pressed
space in the Files panel. So always use line mode for added/deleted files by
default, even if the useHunkModeInStagingView user config is on.
2025-07-27 12:10:25 +02:00
Stefan Haller fc3b725424 Add a test case for a deleted file to TestParseAndFormatPlain
Not because it's terribly important to test here (doesn't hurt though), but
because it will be useful in the next commit for a new test we're adding there.
2025-07-27 12:10:25 +02:00
Stefan HallerandGitHub 16231a150c Show diff for renamed file when filtering by path (#4750)
- **PR Description**

When filtering by file path for a file that was renamed at some point,
we show all commits even before the rename, which is great; however when
you selected a commit before the rename, the diff was empty. The commit
for the rename itself would show the file as added rather than renamed.

This PR fixes that; along the way, we fix the filtered reflog display,
which is supposed to filter by path like the commits view does, but this
didn't work.

Fixes #4510.
2025-07-27 12:09:06 +02:00
Stefan Haller a1aeedd5d5 Fix showing range diff across a rename when filtering by path
We need to pass the union of filter paths at both ends of the range.
2025-07-27 12:05:41 +02:00
Stefan Haller e716617a82 Add test for range diff across rename
When shift-selecting a range of commits across a file rename in
filtering-by-path mode, the diff currently shows an added file rather than a
renamed file. Add a test that demonstrates this, we'll fix this in the next
commit.
2025-07-27 12:05:41 +02:00
Stefan Haller 0f7f1a56df Fix showing diffs for renamed file when filtering by path
When filtering for a file path we use the --follow option for "git log", so it
will follow renames of the file, which is great. However, if you then selected
one of the commits before a rename, you didn't see a diff, because we would pass
the original filter path to the "git show" call.

To fix this, call git log with the --name-status option when filtering by path,
so that each commit reports which file paths are touched in this commit;
remember these in the commit object, so that we can pass them to the "git show"
call later.

Be careful not to store too many such paths unnecessarily. When filtering by
folder rather than file, all these paths will necessarily be inside the original
filter path, so detect this and don't store them in this case.

There is some unfortunate code duplication between loading commits and loading
reflog commits, which I am too lazy to clean up right now.
2025-07-27 12:05:41 +02:00
Stefan Haller 88dae1d8b9 Refactor commit loading and reflog commit loading to extract shared code
These are very similar in that they call RunAndProcessLines on a git log command
and then process lines to create commits. Extract this into a common helper
function. At the moment this doesn't gain us much, but in the next commit we
will extend this helper function considerably with filter path logic, which
would otherwise have to be duplicated in both places.
2025-07-27 12:05:41 +02:00
Stefan Haller e7c33a7a65 Always append -- to git show command
It is good practice to use a -- argument even if no further arguments follow.
Doesn't really make a difference for this particular command though, I think.
2025-07-27 12:05:41 +02:00
Stefan Haller 33a4fdf0ee Remove unnecessary setSubCommits indirection
I don't know why this function argument was added, but I don't like unnecessary
indirections, so I'm removing it as SubCommitsHelper has access to everything it
needs to do it itself.
2025-07-27 12:05:41 +02:00
Stefan Haller e1d728ee5e Fix showing only filtered reflog entries when filtering by path
Recycle reflog commits only for the non-filtered ones.

If we're not filtering, FilteredReflogCommits and ReflogCommits are the same. If
we then enter filtering and get reflog entries again, and pass a
lastReflogCommit, we'd recycle the previous FilteredReflogCommits, which are
unfiltered, so that's no good. Work around this by simply never using the
recycle mechanism when getting the filtered reflog commits.

We could do better by remembering what the last filter path or author was, and
only suppressing the recycling when it changed; but that's more complexity than
I want to add, so hopefully this is good enough.
2025-07-27 12:05:41 +02:00
Stefan Haller 934276ac40 Use the non-filtered reflog for undoing
Using the filtered one is probably not a good idea. It didn't do much harm
because the split of ReflogCommits and FilteredReflogCommits doesn't really work
right now (FilteredReflogCommits is always the same as ReflogCommits, even in
filtering mode), but we'll fix this in the next commit.
2025-07-27 12:05:41 +02:00
Stefan Haller d99ceb91ee Don't get reflog commits twice unnecessarily in filtering mode
I can only guess what happened here: in aa750c0819, this code to manually load
the reflog commits was added, to make sorting branches by recency work when the
reflog is filtered by path. At that time we didn't have separate ReflogCommits
and FilteredReflogCommits models yet. Then, FilteredReflogCommits was introduced
(in 8822c409e2), probably for the very purpose of being able to get rid of this
again; but then it was forgotton to actually get rid of it.

The funny thing is that the introduction of FilteredReflogCommits happened in
the very next commit, 15 minutes later.
2025-07-27 12:05:41 +02:00
Stefan Haller 92b5bad29d Cleanup: simplify git arguments for reflog loading
The combination of --abbrev=40 and %h can be shortened to %H.
2025-07-27 12:05:41 +02:00
Stefan Haller 8515c74722 Add test that demonstrates problem with showing filtered history of file with renames
The test shows that selecting a commit before the rename shows an empty diff,
and selecting the rename itself shows an added file rather than a rename.
2025-07-27 12:05:41 +02:00
Stefan HallerandGitHub b8dfba8b3d Several small fixes to filtering mode (by path or author) (#4749)
- Refresh views properly when entering/exiting filtering mode
- Fix filtering of stashes
2025-07-27 12:05:18 +02:00
Stefan Haller ec82e7c1e7 Make stash filtering work when filtering on a folder 2025-07-27 12:03:06 +02:00