Commit Graph
100 Commits
Author SHA1 Message Date
Stefan Haller d45f27b6ee Add methods for converting RefresherConfig times to time.Durations 2025-11-16 17:32:37 +01:00
Stefan Haller 472b964da3 Cleanup: don't pass refreshInterval to startBackgroundFilesRefresh
It has access to UserConfig, so it can easily get it from there. This is how we
do it for startBackgroundFetch too, so be consistent.
2025-11-16 17:32:37 +01:00
Stefan Haller aff6b642ea Trigger immediate background fetch when switching repos 2025-11-16 17:32:37 +01:00
Stefan Haller 8f4bf49aff Cleanup: remove unused field 2025-11-16 17:32:37 +01:00
Stefan HallerandGitHub ce7622262f feat: add fork remote command (#4831)
The command allows you to quickly add a fork remote by replacing the
owner in the origin URL and optionally check out a branch from new
remote.

Examples:

* given url: `https://github.com/jesseduffield/lazygit.git`
  and username: `karolzwolak`
  
adds a new remote with url: `https://github.com/karolzwolak/lazygit.git`
  
  
* given url: `https://github.com/jesseduffield/lazygit.git`
  and username: `karolzwolak:add-fork-remote-command`
  
adds a new remote with url: `https://github.com/karolzwolak/lazygit.git`
  and then checks out it's branch `add-fork-remote-command`
2025-11-16 17:28:11 +01:00
Stefan HallerandGitHub ba632d4064 Update table of contents in README.md (#5045)
### PR Description
Adding and fixing some links in the table of contents of the README.
2025-11-16 09:10:54 +01:00
Stefan HallerandGitHub 58d2ffa1d6 Suppress output from background fetch (unless there were errors) (#5044)
The output from background fetching is noisy and pollutes the command
log. Don't show it by default, unless there were errors, in which case
it is important to see e.g. which fork was deleted.
2025-11-15 18:32:43 +01:00
Stefan Haller f8a48b61fc Suppress output from background fetch
However, show it when there was an error. This is important for the case that a
fork that you have as a remote was deleted, in which case the command log is the
only way to get notified about that.
2025-11-15 18:27:18 +01:00
Stefan Haller eb91a43d58 Test properties of cmdObj for Push 2025-11-15 18:25:52 +01:00
Stefan Haller 9272276247 Don't log the GetDiff command
This is used for internal purposes and shouldn't pollute the command log.
2025-11-15 18:15:24 +01:00
Stefan HallerandGitHub 933573fd94 Don't allow empty input in most prompts (#5043)
Most of our prompts don't (shouldn't) allow empty input, but most
callers didn't check, and would run into cryptic errors when the user
pressed enter at an empty prompt (e.g. when creating a new branch). Now
we simply don't allow hitting enter in this case, and show an error
toast instead.

This behavior is opt-out, because there are a few cases where empty
input is supported (e.g. creating a stash).
2025-11-15 15:41:54 +01:00
Stefan Haller 95e5ed6f47 Remove TrimSpace calls that are no longer needed
The prompt code takes care of this now.
2025-11-15 15:38:24 +01:00
Stefan Haller 7c126cd2fc Strip leading/trailing whitespace from prompt input
This doesn't really solve a pressing problem, because I guess it's unlikely that
users add spaces at the beginning or end of what they type into a prompt; but it
could happen, and in this case we almost always want to strip it. Just adding
this here for completeness while I was working on this code.

The only exception is the input prompt of custom commands, because who knows
what users want to use that input for in their custom command.
2025-11-15 15:38:24 +01:00
Stefan Haller d7e733cd56 Remove now unnecessary check for empty string
As of the previous commit, branchName can no longer be empty, so no need to
handle this.
2025-11-15 15:38:24 +01:00
Stefan Haller b3435bd59c Add AllowEmptyInput flag to PromptOpts
Most of our prompts don't (shouldn't) allow empty input, but most callers didn't
check, and would run into cryptic errors when the user pressed enter at an empty
prompt (e.g. when creating a new branch). Now we simply don't allow hitting
enter in this case, and show an error toast instead.

This behavior is opt-out, because there are a few cases where empty input is
supported (e.g. creating a stash).
2025-11-15 15:36:43 +01:00
Stefan Haller a7bc1012b9 Cleanup: fix incorrect comment
The comment was apparently copy/pasted from above; the branch name cannot be
blank in this case.
2025-11-15 14:46:19 +01:00
Stefan Haller 48330141bd Cleanup: put the IsPasting logic in the right place
Previously it was used both for the Confirm handler and the Cancel handler, as
well as for the Confirm handler of confirmation popups (not prompts). There was
no other way to do it given how wrappedConfirmationFunction was shared between
all these; but now there is. The logic is really only needed for the Confirm
handler of prompts.

This doesn't fix anything, it just makes things clearer.
2025-11-15 14:13:24 +01:00
Stefan Haller 8d8cf42786 Refactor: extract body of wrappedConfirmationFunction into a helper function
And call this new helper function from both wrappedConfirmationFunction and
wrappedPromptConfirmationFunction; this gives us more flexibility to do
different things in each of those.
2025-11-15 14:07:36 +01:00
Stefan HallerandGitHub 3d5b22f804 Modernize all codes (#5036)
go run
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest
-fix -test ./...
2025-11-15 10:48:35 +01:00
Stefan HallerandGitHub a7126d5456 Allow using SelectedSubmodule in CustomCommands (#5015)
This PR allows the use of `{{ SelectedSubmodule.Path }}`, `{{
SelectedSubmodule.Name }}` and `{{ SelectedSubmodule.Url }}` in custom
commands.
2025-11-12 09:00:22 +01:00
Stefan HallerandGitHub dd04cd8f58 Keep config and schema unchanged during a release (#5010)
Some of our documentation is auto-generated from the source code (the
defaults section in Config.md, and the keybinding cheat sheets), and so
is the JSON schema for the config file. We have a check running on CI
that verifies that when the source code changes (e.g. a new config
option is added), those files are properly regenerated, to make sure
they are always up to date with the latest version of the source code.

This causes a problem when people look at the documentation for a newly
added config option and wonder why it doesn't work in the lazygit
version they are using. Lots of issues were filed where people report
this as a bug, and we have to patiently explain to them that the
documentation describes a feature that hasn't been released yet. A
similar problem occurs when we rename a config option (as has recently
happened with the 'paging' config, which was renamed to 'pagers' in
#4953), in which case the user's editor (if it supports JSON validation
against the jsonschema store) starts to complain about the old config,
even though it still works, and the new one doesn't yet.

To solve this, keep the documentation and the JSON schema unchanged for
the lifetime of a release; make those continuous changes in a separate
copy of those folders, and only copy the files back to the real location
right before we make a release. To facilitate this, we add a script to
conveniently create a PR for copying the files back, and add a check to
the release workflow to abort with an error if this was forgotten.

Note that we only use this approach in order to solve the problem with
the auto-generated files; this has a consequence for making changes to
the other, non-auto-generated parts of the docs. For example, when
fixing a spelling error, rewording a paragraph to explain it better, or
adding an entirely new file, those changes will now have to be made in
docs-master, which means:
1. if we forget this and make the change in `docs` accidentally, it will
be reverted with the next release.
2. if we do remember to make the change in docs-master, it will take
until the next release for it to be visible to users.

We can mitigate 2. by making the identical change in both places, but I
think we should first wait and see how often it happens, and whether it
is actually a problem.
2025-11-12 08:47:11 +01:00
Stefan Haller 6ab40df429 Add a check to the release workflow to abort if docs or schema are not up to date
Of course it would be cooler if the workflow could create the PR and merge it if
necessary, but this will have to do for now.
2025-11-12 08:44:56 +01:00
Stefan Haller 7ce1501f3e Add a script for copying the docs and schema over for release
This needs to be run immediately before creating a release.

We could go further here and use gh to create the PR, but since I'm usually
logged in with my work account to gh, this won't help me. The git push command
prints the URL to create the PR, so it's a simple matter of command-clicking it,
which is good enough for me.
2025-11-12 08:44:56 +01:00
Stefan Haller 7627da594d Update generators to change the files in the -master directories 2025-11-12 08:44:56 +01:00
Stefan Haller d5677318ab Make copies of the docs and schema folders
The plan is to keep the original docs and schema folders unchanged for the
duration of a release; we'll only continuously update the -master copies. Right
before a new release we will copy them over.
2025-11-12 08:44:56 +01:00
Stefan Haller e3a1fe514c Make link relative
This way it will also work when we make a copy of the entire docs folder.
2025-11-12 08:44:56 +01:00
Stefan HallerandGitHub 42e4232e56 Keep cursor at top/bottom when navigating by page (#5019)
When pressing '.' (next page) or ',' (previous page), the selection now
stays at the bottom or top of the viewport respectively, instead of
being centered which caused items to scroll off. (If the selection is
not already on the last/first line of the view, '.'/',' moves it there
without scrolling.)

This implements a special case for page navigation as suggested by the
maintainer in issue #5017, keeping the cursor position consistent with
user expectations for page-based navigation.

Fixes #5017
2025-11-09 19:43:48 +01:00
Stefan Haller 2576258ba3 Cleanup: remove unnecessary code
The method is only called from keybinding handlers, so the view must be focused
already, otherwise the binding wouldn't have been dispatched to it.
2025-11-09 19:37:38 +01:00
Stefan HallerandGitHub 9c0cbd83c7 Open pull requests in browser with extra leading slashes removed (#5018)
### PR Description

This allows for having extra slashes in git URLs. Especially in
submodules. Those may be used to avoid warnings with older bitbake
fetcher implementations in yocto. Which warns about relative urls when
not having a slash in git urls.

- git@bitbucket.org:project/repo.git -> generates a warning in bitbake,
which is annoying.
- git@bitbucket.org:/project/repo.git -> does not generate a warning in
bitbake.

But when trying to open a PR from lazygit with an url like
git@bitbucket.org:/project/repo.git leads to
https://bitbucket.org//project/repo being opened and one has to stare at
a blank page unless one removes the extra / manualy.

This PR updates the regex used for matching git url fragments in a way,
that the extra `/` is ignored.
2025-11-07 16:23:08 +01:00
Stefan HallerandGitHub 1d17507795 Add a "Commit history" section to CONTRIBUTING.md (#5022)
I see too many PRs with terrible commit histories; maybe this will help
a bit with that.
2025-11-07 13:20:50 +01:00
Stefan Haller 6ff18bbc36 Add a "Commit history" section to CONTRIBUTING.md
I see too many PRs with terrible commit histories; maybe this will help a bit
with that.
2025-11-07 13:12:09 +01:00
Stefan Haller 6aea67ca50 Cleanup: format markdown
I want to be able to press Command-S in VS Code and not have it reformat code
that I didn't edit.
2025-11-07 12:28:15 +01:00
Stefan HallerandGitHub aa2bdb0091 README.md: Update Sponsors (#4946)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action
2025-11-02 07:52:00 +01:00
Stefan HallerandGitHub 80223c7fbb Fix keybinding cheatsheets with regard to pipe characters in key or description (#5007)
The "Cycle pagers" command wasn't rendered correctly, because it's bound
to '|' by default, but this was taked as a table column delimiter. Fix
this by escaping the pipe character.

A similar thing could happen for the description or tooltip (and did in
fact, for a tooltip in the russion translation), so escape those too
just to be sure.
2025-11-01 09:56:57 +01:00
Stefan Haller ff0a16f809 Fix keybinding cheatsheets with regard to pipe characters in key or description
The "Cycle pagers" command wasn't rendered correctly, because it's bound to '|'
by default, but this was taked as a table column delimiter. Fix this by escaping
the pipe character.

A similar thing could happen for the description or tooltip (and did in fact,
for a tooltip in the russion translation), so escape those too just to be sure.
2025-11-01 09:54:32 +01:00
Stefan HallerandGitHub 48c1db6fe4 Fix fixup's false filename detection in hunks containing dashed lines (#5004)
### PR Description

The existing diff parser incorrectly treated subsequent lines beginning
with `---` as filename headers while processing hunks. This caused
corruption when dashed lines appeared within diffs themselves.

Restrict filename detection to only occur between hunks.

This repository https://github.com/abobov/lazygit-fixup-issue
demonstrates the issue:

- clone repository
- run `git reset --soft HEAD~`
- try `<c-f>` Find base commit for fixup 
- `fatal: no such path ...` error
2025-11-01 09:42:45 +01:00
Stefan HallerandGitHub f4920e8efa Use a PTY when using external diff command from git config (#4983)
### PR Description

I hit the same issue as
https://github.com/jesseduffield/lazygit/issues/3119 when setting
`useExtDiffGitConfig` to true and using `difftastic` side-by-side
comparison in my git config.

The same fix in https://github.com/jesseduffield/lazygit/pull/3120 needs
to be applied for the newer config option.
2025-11-01 09:35:45 +01:00
Stefan HallerandGitHub 6f0f1e7995 Update translations from Crowdin (#5005) 2025-10-31 19:58:37 +01:00
Stefan Haller 3967edd113 Update translations from Crowdin 2025-10-31 19:56:01 +01:00
Stefan HallerandGitHub 32a701cb9c Use ignore directive to ignore test files not to be passes to gofumpt (#4936)
### Motivation
To replace the workaround introduced in
https://github.com/jesseduffield/lazygit/pull/4809 with `ignore`
directive to make the code simpler.

### Overview
This is a follow-up PR to
https://github.com/jesseduffield/lazygit/pull/4809.
I have added 4 changes due to updating gofumpt to remove `git ls-files`
workaround.

Please take a look at each commit messages for details.
2025-10-20 07:59:40 +02:00
Stefan HallerandGitHub 6782f04e8c Add no-ff merge option (#4966)
This will put whatever git's default merge variant is as the first menu
item, and add a second item which is the opposite (no-ff if the default
is ff, and vice versa). Which one is the default depends on whether a
fast-forward merge is possible, and whether users have set git's
`merge.ff` config or lazygit's `git.merging.args` config.

If users prefer to always have the same option first no matter whether
it's applicable, they can make ff always appear first by setting git's
`merge.ff` config to "true" or "only", or by setting lazygit's
`git.merging.args` config to "--ff" or "--ff-only"; if they want no-ff
to appear first, they can do that by setting git's `merge.ff` config to
"false", or by setting lazygit's `git.merging.args` config to "--no-ff".
Which of these they choose depends on whether they want the config to
also apply to other git clients including the cli, or only to lazygit.

Closes #4091.
2025-10-19 21:26:31 +02:00
Stefan Haller 62854026a3 Add no-ff merge option
This will put whatever git's default merge variant is as the first menu item,
and add a second item which is the opposite (no-ff if the default is ff, and
vice versa).

If users prefer to always have the same option first no matter whether it's
applicable, they can make ff always appear first by setting git's "merge.ff"
config to "true" or "only", or by setting lazygit's "git.merging.args" config to
"--ff" or "--ff-only"; if they want no-ff to appear first, they can do that by
setting git's "merge.ff" config to "false", or by setting lazygit's
"git.merging.args" config to "--no-ff". Which of these they choose depends on
whether they want the config to also apply to other git clients including the
cli, or only to lazygit.
2025-10-19 21:24:28 +02:00
Stefan Haller c88381b9ce Rename texts to be consistent with our conventions 2025-10-19 21:24:28 +02:00
Stefan Haller afbef40258 Reorder texts so that they are grouped together, and ordered in a sensible way 2025-10-19 21:24:28 +02:00
Stefan Haller 4e0194d8f7 Replace MergeOpts struct with MergeVariant enum
- Squash and FastForwardOnly are mutually exclusive, and instead of asserting
  this at runtime, model the API so that they can't be passed together.
- FastForwardOnly is unused, so remove it; however, we are going to need --ff
  and --no-ff in the next commit, so add those instead.
- Instead of putting the enum into the MergeOpts struct, replace the struct by
  the enum. We can reintroduce the struct when we add more arguments, but for
  now it's an unnecessary indirection.
2025-10-19 21:24:28 +02:00
Stefan HallerandGitHub d334bae0a0 Add synchronize event to the hooks of "Check Required Labels" (#4974)
I found that PR status becomes green even if no label added when we use
`Update branch` on GitHub PR page.

So I added `synchronize` event to the hooks of `Check Required Labels`.
2025-10-19 17:29:17 +02:00
Stefan HallerandGitHub a22aced1bb Avoid auto-stashing when only submodules are out of date (#4969)
Stashing doesn't affect submodules, so if you have a working copy that
has out-of-date submodules but no other changes, and then you revert or
paste a commit (or invoke one of the many other lazygit commands that
auto-stash, e.g. undo), lazygit would previously try to stash changes
(which did nothing, but also didn't return an error), perform the
operation, and then pop the stash again. If no stashes existed before,
then this would only cause a confusing error popup ("error:
refs/stash@{0} is not a valid reference"), but if there were stashes,
this would try to pop the newest one of these, which is very undesirable
and confusing.
2025-10-16 12:08:48 +02:00
Stefan Haller 40cc008a5a Avoid auto-stashing when only submodules are out of date
Stashing doesn't affect submodules, so if you have a working copy that has
out-of-date submodules but no other changes, and then you revert or paste a
commit (or invoke one of the many other lazygit commands that auto-stash, e.g.
undo), lazygit would previously try to stash changes (which did nothing, but
also didn't return an error), perform the operation, and then pop the stash
again. If no stashes existed before, then this would only cause a confusing
error popup ("error: refs/stash@{0} is not a valid reference"), but if there
were stashes, this would try to pop the newest one of these, which is very
undesirable and confusing.
2025-10-16 12:00:31 +02:00
Stefan HallerandGitHub 7282159f78 Show a better error message if the temp directory is not writeable (#4968)
This happened to a few users after updating macOS to version 15.7.1, and
apparently a reboot fixes it, so suggest this in the error message.

Closes #4924
2025-10-16 10:10:30 +02:00
Stefan Haller e02f073cd0 Show a better error message if the temp directory is not writeable
This happened to a few users after updating macOS to version 15.7.1, and
apparently a reboot fixes it, so suggest this in the error message.
2025-10-16 10:04:47 +02:00
Stefan HallerandGitHub 853b54b069 Add config option gui.skipSwitchWorktreeOnCheckoutWarning (#4964)
Adds a config option that disables the confirmation for switching to a
worktree when trying to check out a branch that is checked out in that
other worktree.

Fixes #4938.
2025-10-14 14:24:36 +02:00
Stefan Haller 80f860beb7 Add config option gui.skipSwitchWorktreeOnCheckoutWarning 2025-10-14 14:19:54 +02:00
Stefan HallerandGitHub d3fb22a673 Fix lazygit getting unresponsive when pasting commits that become empty (#4958)
Lazygit would become unresponsive when cherry-picking a commit that
becomes empty at the destination. There are two ways this can happen:
one where a cherry-picked commit simply becomes empty "by itself",
because the change is already present on the destination branch (this
was only a problem with git versions older than 2.45), and another where
the cherry-pick stops with conflicts, and the user resolves them such
that no changes are left, and then continues the cherry-pick. This would
still fail even with git 2.45 or later. The fix is the same for both
cases though.

Fixes #4763.
2025-10-14 12:30:15 +02:00
Stefan Haller 3ac9003298 Add tests
I can't do my usual "add the tests first, with EXPECTED/ACTUAL sections that
document the bug" method here, because the tests would hang without the bug
being fixed.

We need two different tests here: one where a cherry-picked commit simply
becomes empty "by itself", because the change is already present on the
destination branch (this was only a problem with git versions older than 2.45),
and the other where the cherry-pick stops with conflicts, and the user resolves
them such that no changes are left, and then continues the cherry-pick. This
would still fail even with git 2.45 or later. The fix is the same for both cases
though.

The tests show that the selection behavior after skipping an empty cherry-picked
commit is not ideal, but since that's only a minor cosmetic problem we don't
bother fixing it here.
2025-10-14 12:27:32 +02:00
Stefan Haller e858bad3f8 Fix lazygit getting unresponsive when pasting commits that become empty
Whenever git returns the error "The previous cherry-pick is now empty", we would
previously continue the rebase; this works for rebase because it behaves the
same as "git rebase --skip" in this case. That's not true for cherry-pick
though; if you continue a cherry-pick where the current commit is empty, it will
return the same error again, causing lazygit to be stuck in an endless loop.

Fix this by skipping instead of continuing; this shouldn't make a difference for
rebase, but works for cherry-pick.

Theoretically we could have a similar problem for revert (if you are trying to
revert a commit that has already been undone through some other means); this
should then be fixed in the same way with this change. However, the change is
not relevant for revert because git returns a different error in this case.
2025-10-14 12:27:32 +02:00
Stefan HallerandGitHub 9adcc8ec79 Fix window arrangement when a popup or the search prompt is open (#4961)
When focusing the main view, going into full screen mode by pressing '+'
twice, and then opening the search prompt ('/') or a menu (e.g. '?' or
':'), the full screen display would switch to the focused side panel.

Fix this by always excluding popups from the window arrangement logic.
No popup should ever have any influence on how the views beneath it are
laid out.

Addresses [this detail
aspect](https://github.com/jesseduffield/lazygit/issues/1113#issuecomment-3206883422)
of #1113.
2025-10-14 12:27:16 +02:00
Stefan Haller 8eeb16c8da Fix window arrangement when a popup or the search prompt is open
When focusing the main view, going into full screen mode by pressing '+' twice,
and then opening the search prompt ('/') or a menu (e.g. '?' or ':'), the full
screen display would switch to the focused side panel.

Fix this by always excluding popups from the window arrangement logic. No popup
should ever have any influence on how the views beneath it are laid out.
2025-10-14 12:22:58 +02:00
Stefan HallerandGitHub 442ede95c2 Offer to force-delete a worktree if it contains submodules (#4959)
For a worktree that contains submodules, trying to delete it would show
an error instead of offering to force-remove it.

Fixes #4125.
2025-10-14 12:22:38 +02:00
Stefan Haller 3415ed975b Offer to force-delete a worktree if it contains submodules 2025-10-14 12:19:49 +02:00
Stefan Haller 7568f5bf05 Add test demonstrating the problem
For a worktree that contains submodules, trying to delete it shows an error and
doesn't offer to force-remove it.
2025-10-14 12:19:49 +02:00
Stefan HallerandGitHub 5812466145 Support multiple pagers (#4953)
Allow configuring an array of pagers, and cycling through them with the
`|` key (mnemonic: we are piping the output through something). I find
this useful for switching between delta (which I prefer most of the
time) and difftastic (which occasionally produces better output for
certain kinds of changes). It could also be used to switch between delta
in inline mode and in side-by-side mode.
2025-10-14 12:19:32 +02:00
Stefan Haller 32bf6d685c Add config migration of paging section to pagers array 2025-10-14 12:17:13 +02:00
Stefan Haller 823b2e9aab Update cheatsheets 2025-10-14 12:17:13 +02:00
Stefan Haller e44d6ec330 Replace paging config with an array of pagers 2025-10-14 12:17:13 +02:00
Stefan Haller 765c9eb85c Add PagerConfig
This is an object that is owned by Gui, is accessible through GuiCommon.State(),
and also passed down to GitCommand, where it is mostly needed. Right now it
simply wraps access to the Git.Paging config, which isn't very exciting, but
we'll extend it in the next commit to handle a slice of pagers (and maintain the
currently selected pager index), and doing this refactoring up front allows us
to make that change without having to touch clients.
2025-10-14 12:17:13 +02:00
Stefan Haller ed05470732 Cleanup: remove unused method ConfiguredPager
This could have been removed in commit 9657b4346f.
2025-10-14 12:17:13 +02:00
Stefan HallerandGitHub 1c87776470 When pasting multi-line text into a prompt, don't treat the line feeds as "confirm" (#4955)
This is likely to do bad things; for example, if the prompt is the shell
command prompt, then we would run into what looks like a deadlock bug in
tcell. In other cases, the characters in the following lines might be
treated as random keybindings after the prompt is confirmed; this is
very similar to #4234.

In this case, it seems the best we can do is to simply swallow the line
feeds. The entire pasted text will then appear as a single long line in
the prompt, and hopefully the user knows that they can use ctrl-u to
delete it again. If not, they will probably just hit esc to close the
prompt.

Fixes #4954.
2025-10-14 12:15:44 +02:00
Stefan Haller fbaea583a5 When pasting multi-line text into a prompt, don't treat the line feeds as "confirm"
This is likely to do bad things; for example, if the prompt is the shell command
prompt, then we would run into what looks like a deadlock bug in tcell. In other
cases, the characters in the following lines might be treated as random commands
after the prompt is confirmed.
2025-10-14 12:10:51 +02:00
Stefan HallerandGitHub 6b5b493237 Fix support for Git copy status when status.renames=copies (#4892)
Fixes: #4890

- Fix file status parsing to handle Git copy operations when
`status.renames=copies` is configured
- Extend status parser to recognize both "R" (rename) and "C" (copy)
prefixes
- Add comprehensive test coverage for copy status codes

The same issue from https://github.com/jesseduffield/lazygit/issues/4890
now is fixed

<img width="602" height="453" alt="image"
src="https://github.com/user-attachments/assets/c5b0dc4b-8f77-4867-b601-65faa91d6607"
/>
2025-10-14 12:07:04 +02:00
Stefan HallerandGitHub f7a4092a29 Wrap long lines in comments in Config.md (#4951)
Since these are displayed in a fenced code block on github, they aren't
auto-wrapped on display, so users have to scroll horizontally to read
longer paragraphs.

Addresses
https://github.com/jesseduffield/lazygit/issues/800#issuecomment-3209372957.
2025-10-10 21:27:56 +02:00
Stefan Haller db9fb216fd Wrap long comment lines in Config.md 2025-10-10 21:25:02 +02:00
Stefan Haller c9eef8079e Add missing Portuguese language 2025-10-10 21:25:02 +02:00
Stefan Haller 396f87b46b Unwrap paragraphs in user_config comments
We want to switch to have paragraphs consistently on one line, and auto-wrap
them automatically when generating Config.md.

The changes to Config.md in this commit are temporary.
2025-10-10 21:25:02 +02:00
Stefan HallerandGitHub 30169bd258 Fix dropping submodule changes from a commit (#4937)
Our logic to decide if a file needs to be checked out from the previous
commit or deleted because it didn't exist in the previous commit didn't
work for submodules. We were using `git cat-file -e` to ask whether the
file existed, but this returns an error for submodules, so we were
always deleting those instead of reverting them back to their previous
state.

Switch to using `git ls-tree -- file` instead, which works for both
files and submodules.

Fixes #4932.
2025-10-10 12:58:06 +02:00
Stefan Haller c1e52fc807 Fix dropping submodule changes from a commit
Our logic to decide if a file needs to be checked out from the previous commit
or deleted because it didn't exist in the previous commit didn't work for
submodules. We were using `git cat-file -e` to ask whether the file existed, but
this returns an error for submodules, so we were always deleting those instead
of reverting them back to their previous state.

Switch to using `git ls-tree -- file` instead, which works for both files and
submodules.
2025-10-10 12:55:58 +02:00
Stefan Haller 0904bf9969 Add test demonstrating the problem
When dropping changes to the submodule, we expect it to get rolled back to the
previous version; however, it is removed entirely instead.
2025-10-10 12:55:58 +02:00
Stefan Haller 21483b259c Rename AddFileInWorktree to AddFileInWorktreeOrSubmodule
It works for submodules too.

Also, pass file name and file content explicitly; the existing tests don't care
about these, but when writing tests that do, it makes them easier to understand.
2025-10-10 12:55:58 +02:00
Stefan HallerandGitHub 8e00bbd939 Show "Log (x of y)" in the title bar when there is more than one branch log command (#4943)
Addresses #4939.
2025-10-10 12:51:54 +02:00
Stefan Haller 5d02cba721 Show "Log (x of y)" in the title bar when there is more than one branch log command 2025-10-10 12:49:42 +02:00
Stefan Haller bf56a61b71 Change condition that determines whether we are showing the dashboard
Doesn't make a difference currently, since the title is either StatusTitle when
the dashboard is showing, or LogTitle when one of the branch logs is showing.
This is going to change in the next commit, though.
2025-10-10 12:49:42 +02:00
Stefan Haller 220cde1376 Fix potential crash when reloading the config after removing a branch log command
When cycling to the last branch log command, and then editing the config to
remove one or more log commands, lazygit would crash with an out of bounds panic
when returning to it. Fix this by resetting the log index to 0 when it is out of
bounds. (I think resetting to 0 is better than clamping, although it doesn't
matter much.)
2025-10-10 12:49:42 +02:00
Stefan Haller 19f88290a2 Change allBranchesLogCmdIndex to an int
I know that uint was chosen to document that it can't be negative (not sure why
the "8" was chosen, though). That's pointless in languages that don't enforce
this though: you can subtract 1 from uint8(0) and you'll get something that
doesn't make sense; that's not any better than getting -1. I'm not a fan of
using unsigned types in general (at least in languages like go or C++), and they
usually just make the code more cumbersome without real benefits.
2025-10-10 12:49:42 +02:00
Stefan HallerandGitHub 47ca08240b Don't depend on en_US locale to be installed (#4949)
For some of the git commands that lazygit uses, it needs to force the
language to English because it parses git's output and needs to react to
certain things. It used to do this by setting the locale to
`en_US.UTF-8`; some users reported that this locale isn't available on
their systems. Use the "C" locale instead, which achieves the same
result and is guaranteed to be available everywhere.

Fixes #4731.
2025-10-09 13:19:58 +02:00
Stefan Haller 99a83efc34 Set LC_MESSAGES too
I'm not sure this is necessary, but it doesn't hurt.
2025-10-09 13:10:58 +02:00
Stefan Haller b755f52754 Use C locale instead of en_US.UTF-8 to force English language
Some users reported that en_US.UTF-8 is not available on their systems, leading
to warnings in the command log. "C" also forces the language to English, and is
guaranteed to be available everywhere.
2025-10-09 13:10:02 +02:00
Stefan HallerandGitHub c31b604c9d Document a workaround for using custom pagers on Windows (#4941)
Custom pagers are not supported on Windows, because using a pager in git
requires the git command to run in a PTY, but the PTY package we are
using doesn't support Windows.

However, there's a workaround to use a custom pager by using a
Powershell script configured as an external diff command. Document this
in the `Custom_Pagers.md` document, and export a `LAZYGIT_COLUMNS`
environment variable to allow such scripts to work better.
2025-10-09 10:06:44 +02:00
Stefan HallerandGitHub 4b59f9855e When entering a commit in path filtering mode, select the filtered path (#4942)
This can be useful if you want to do some operation on the filtered
file, e.g. check it out using `c`, or enter the file to make a custom
patch from it.

Addresses #4935.
2025-10-09 10:00:38 +02:00
Stefan Haller 7fe73c1ee2 When entering a commit in path filtering mode, select the filtered path 2025-10-09 09:58:15 +02:00
Stefan Haller 5811f2945c Extract a InternalTreePathForFilePath helper function 2025-10-09 09:58:10 +02:00
Stefan HallerandGitHub fb00584f4d Update diff of conflicted file in the main view after conflicts have been resolved (#4945)
When lazygit detects that all conflicts have been resolved, it puts up a
popup asking whether the user wants to continue the merge or rebase.
However, it didn't rerender the main view of the conflicted file, so it
would still show the conflict markers, which is confusing. Add some
logic that updates the main view in this situation, behind the popup.
2025-10-09 09:04:32 +02:00
Stefan Haller 5fad3ab047 Refresh the main view for the current side panel when a popup is showing
The logic in postRefreshUpdate would only rerender the main view if the context
being updated is the current view. This is not the case when a popup is showing;
but we still want to render the main view in that case, behind the popup. This
happens for example when we refresh the Files scope, we determine that all
conflicts have been resolved and show a popup asking to continue the merge or
rebase, but the postRefreshUpdate of the Files context only happens when the
popup is already showing, so we would still see the conflict markers behind the
popup, which is rather confusing.
2025-10-09 09:02:03 +02:00
Stefan HallerandGitHub 3f30008224 Add merge menu with conflict resolver (#4889)
Implements https://github.com/jesseduffield/lazygit/issues/2026. I also
tried to address issues mentioned in the
https://github.com/jesseduffield/lazygit/pull/3477 PR.

Previously, pressing `M` opened an external merge tool. Now it opens a
merge options menu that allows selecting all conflicts in chosen files
as **ours** (HEAD), **theirs** (incoming), or **union** (both), while
still providing access to the external merge tool.

This uses [git-merge-file](https://git-scm.com/docs/git-merge-file) for
a 3-way merge with the `--ours`, `--theirs`, and `--union` flags. This
approach avoids the issue mentioned in
https://github.com/jesseduffield/lazygit/discussions/1608#discussioncomment-13002595,
and correctly applies the chosen conflict resolutions while preserving
changes from other branches. The command is executed with `--object-id`,
which requires object IDs obtained via `rev-parse`, instead of relying
on the standard version that works with full saved files.
2025-10-09 08:51:04 +02:00
Stefan HallerandGitHub 1f002af06b fix(nix): use nixos-unstable (#4948)
Fixed jesseduffield/lazygit#4947
2025-10-09 08:43:26 +02:00
Stefan HallerandGitHub 60a7d6ac57 Fix normalisedSelectedNodes function (#4920)
The `normalisedSelectedNodes` function in `files_controller.go` had a
bug where it didn't work correctly for the root item (`/`). This PR
fixes that.

We don't have any tests for this bug. Apparently, the functions that use
this (staging and discarding files) also work correctly when they work
on a directory and then on the contained file again, that's why nobody
has noticed yet. I briefly looked into adding unit tests for the
function, but it was more work than I was willing to put into this right
now.
2025-10-08 15:12:03 +02:00
Stefan Haller 302b621b68 Fix: make isDescendentOfSelectedNodes work for the root item
The root item's path is ".", and the path of a file at top level is "./file".
When using GetPath, this gives us "." and "file", respectively, and
isDescendentOfSelectedNodes would return false for these.

Working with the internal paths (i.e. without stripping the leading "./") fixes
this.
2025-10-08 15:09:35 +02:00
Stefan Haller d0c6e27fee Cleanup: move variable assignment out of the loop
It never changes inside this function, so there's no need to recompute it with
every loop iteration.
2025-10-08 15:09:35 +02:00
Stefan HallerandGitHub 6478bf456b feat(nix): add comprehensive Nix flake (#4826)
## PR Description

This PR adds Nix flake support to provide a reproducible development
environment and build process for `lazygit` contributors, devs, and
users.

Features:
- Nix Flake Configuration: Complete flake setup supporting multiple
architectures
- Development Shell: Pre-configured environment with Go toolchain,
linting tools, and development utilities
- Multiple Entry Points: Support for `nix develop`, `nix run`, and `nix
build`

Closes #3474.
2025-10-08 15:08:44 +02:00
Stefan HallerandGitHub 97762f484f Update Merge conflicts menu keybinding to use p instead of k (#4934) 2025-10-05 10:26:33 +02:00
Stefan HallerandGitHub f45e7ca705 Update go to 1.25 (#4844)
### PR Description
This PR includes 2 changes:
1. Bump golangci-lint version to `v2.4.0` from  `v.2.2.1`
1. Bump Go version to `1.25.0`:
	- Bump Go version to `1.25` in `go.mod`
	- Bump Go version to  `1.25` in `ci.yml`
	- Bump base image to `golang:1.25`  in `Dockerfile`

### Reference
- [Go 1.25 release note](https://tip.golang.org/doc/go1.25)
2025-10-05 10:21:49 +02:00
Stefan HallerandGitHub 7544de03c0 Give better visual feedback when checking out the previous branch (#4929)
I find the command "Checkout previous branch" quite useful, and I use it
a lot. However, I'm unhappy with the visual feedback, so this PR
improves that a bit.

Previously, the feedback you got when pressing "-" was just a "Checking
out..." status in the bottom line. This was both easy to miss if you are
used to looking for an inline status in the branches panel, and it
didn't provide information about which branch was being checked out,
which can be annoying in very large repos where checking out takes a
while, and you only see at the end if you are now on the right branch.

Improve this by trying to figure out which branch was the previously
checked out one, and then checking it out normally so that you get an
inline status next to it (as if you had pressed space on it). There are
cases where this fails, e.g. when the previously checked out ref was a
detached head, in which case we fall back to the previous behavior.
2025-10-05 10:04:06 +02:00