Commit Graph
100 Commits
Author SHA1 Message Date
Stefan Haller 9290c074f7 Update translations from Crowdin 2025-07-04 18:22:13 +02:00
Stefan HallerandGitHub ca06ce6100 Collapse selection after deleting a range of branches or stashes (#4661)
- **PR Description**

Fixes selection state persistence after deletion by resetting selection
mode.
Resolves [#4612](https://github.com/jesseduffield/lazygit/issues/4612)
2025-07-04 17:34:33 +02:00
Stefan Haller 4b33efffbe Collapse selection after deleting a range of remote branches
We only want to do this when the function is called from the remote branches
panel. It can also be called with a selection of local branches in order to
delete their remote branches, but in this case the selection shouldn't be
collapsed because the local branches stay around.
2025-07-04 17:20:22 +02:00
Stefan Haller 80a614d330 Fix collapsing the range selection after deleting branches
We had code already that was supposed to do this, but it didn't work. It should
have used SetSelection() instead of SetSelectedLineIdx(); the latter doesn't
actually cancel a range selection.

Introduce a new function specifically for collapsing the range after deleting
multiple items, so that clients don't need two calls (we'll add a bunch more in
this branch).
2025-07-04 17:18:10 +02:00
Stefan HallerandGitHub 61ff8a4da8 Move to next stageable line when adding a line to a custom patch (#4675)
- **PR Description**

While it's true that the behavior is a little different from the staging
panel, where the staged lines are actually removed from the view and in
many cases the selection stays more or less in the same place, it is
still very useful to move to the next stageable thing in the custom
patch building view too.

Also, we change the visualization of what's included in the patch to
mark only the + and - lines of the patch; for all other lines it doesn't
make a difference whether they are included.

And finally, we make it so that only + and - lines are considered when
pressing space; previously it would also look at selected context lines,
which doesn't make much sense. This improves the experience for mouse
users who like to generously select hunks by dragging across them,
including some context lines above and below.
2025-07-04 10:16:45 +02:00
Stefan Haller 039831a27a Move to next stageable line after adding a line to a custom patch
While it's true that the behavior is a little different from the staging panel,
where the staged lines are actually removed from the view and in many cases the
selection stays more or less in the same place, it is still very useful to move
to the next stageable thing in the custom patch building view too.
2025-07-04 10:14:35 +02:00
Stefan Haller ce9fbe58b2 Toggle only added/deleted lines in patch building view
This improves the experience when selecting a hunk generously with the mouse, by
dragging over it including some context lines above and below. Previously we
would consider the "moving end" of the selection range for whether things need
to be added or removed, but this doesn't make sense if it's a context line. Now
we consider the first actual change line that is included in the range.
2025-07-04 10:14:35 +02:00
Stefan Haller ef1a141347 Export PatchLine.isChange 2025-07-04 10:14:35 +02:00
Stefan Haller 42bbe965fa Render only + and - lines as included in a patch
It is confusing to get header lines, hunk headers, or context lines rendered as
being included in a custom patch, when including these makes no difference to
the patch.

This is only a visual change; internally, we still record these non-patch lines
as being included in the patch. It doesn't matter though; you can press space on
a header line and nothing happens.

It would probably be cleaner to only record + and - lines in the includedLines
array, but that would be a bit more work, and doesn't seem worth it.
2025-07-04 10:14:35 +02:00
Stefan HallerandGitHub a8e98593ea Auto-stash modified files when cherry-picking or reverting commits (#4683)
- **PR Description**

For cherry-picking, this used to work in earlier versions, but it broke
in #4443. For reverting, it was never supported.

Also, we add some minor improvements while we're at it, such as slightly
better names for the auto-stashes that are created for the various
operations (so that, if an auto-stash pop fails and the stash is kept
around, you can tell more easily what it was for). Also, we now adjust
the selection of the commits list after cherry-picking, so that the same
commit stays selected.
2025-07-04 10:13:52 +02:00
Stefan Haller 6b1cab7011 Auto-stash if necessary when reverting commits 2025-07-03 17:04:10 +02:00
Stefan Haller dc795b5db7 Remove unnecessary refresh
CheckMergeOrRebase calls Refresh already. However, it does an async refresh by
default, so we must turn this into a sync refresh so that moving the selection
down by one works even for the very first commit in history. Also, we must add
an explicit call to FocusLine so that the view selection is in sync with the
model selection; previously this was taken care of by the PostRefreshUpdate call
that happens as part of a refresh.
2025-07-03 17:04:10 +02:00
Stefan Haller 0fc107c8c1 Adjust selection after cherry-picking commits
Keep the same commit selected, by moving the selection down by the number of
cherry-picked commits. We also do this when reverting commits, and it is
possible now that we use a sync waiting status.

We also need to turn the refresh that happens as part of CheckMergeOrRebase into
a sync one, so that the commits list is up to date and the new selection isn't
clamped.
2025-07-03 17:04:10 +02:00
Stefan Haller 09a4e0b209 Add selection assertions to cherry-pick tests
We are about to change the selection behavior when cherry-picking, and it's good
to have tests that document in what way it changes in the next commit.
2025-07-03 16:58:56 +02:00
Stefan Haller 6479c52fb2 Use sync waiting status for cherry-picking
This reduces flicker of the Files panel in the case that an auto-stash needs to
be made.
2025-07-03 16:58:56 +02:00
Stefan Haller 3f3e942f60 Auto-stash if necessary when cherry-picking commits 2025-07-03 16:58:56 +02:00
Stefan Haller e7cb469fd0 Remove unused text StashPrefix 2025-07-03 16:56:30 +02:00
Stefan Haller 9511ed9d2c Use a better name for the auto-stash for moving a custom patch to index 2025-07-03 16:56:30 +02:00
Stefan Haller 2a7ce19b73 Use a better name for the auto-stash for creating a new branch
For the case of creating a new branch by moving commits to it, we were using the
current (old) branch name in the stash name; change this to use the new name
instead.
2025-07-03 16:56:30 +02:00
Stefan Haller 908975c758 Use a better name for the auto-stash for checking out a branch 2025-07-03 16:53:49 +02:00
Stefan Haller a83fc5e343 Use a better name for the auto-stash for undo 2025-07-03 16:53:49 +02:00
Stefan Haller 2c206c374d Use abbreviated hash in undo confirmations 2025-07-03 16:53:49 +02:00
Stefan Haller 50785a2217 Exclude vendor directory from linting
It seems to be excluded already when you run the lint.sh script, but in VS Code
when setting Lint on Save to package it would still lint a file in gocui when
you save it, which is annoying. (Remove the other paths that were there before;
they seem to be unused, and they were added by the auto-migration.)

Unfortunately, gopls will still lint gocui files with its builtin staticcheck
linter, and I couldn't find a way to turn this off. This might be a reason to
turn off staticcheck in gopls (not sure yet).
2025-07-03 16:39:52 +02:00
Stefan HallerandGitHub 91d8c25183 Fix applying custom patches to a dirty working tree (#4674)
- **PR Description**

Applying or reverting a custom patch when one of the files contained in
the patch had unstaged modifications in the working tree would fail with
the confusing error message "does not match index", regardless of
whether those modifications conflicted with the patch or not. You would
expect this to just work if there are no conflicts, or to get the usual
conflict markers if there are. It was possible to work around this by
manually staging those files, but few people knew about this. Fix this
by staging the files (after asking for confirmation).

Also, fix a minor problem where an auto-stash for the "move patch to
index" command was forgotten to be dropped.
2025-07-02 16:32:32 +02:00
Stefan Haller 3df894ec92 Stage affected unstaged files when applying or reverting a patch
Unlike moving a patch to the index, applying or reverting a patch didn't
auto-stash, which means that applying a patch when there's a modified (but
unstaged) file in the working tree would error out with the message "error:
file1: does not match index", regardless of whether those modifications conflict
with the patch or not.

To fix this, we *could* add auto-stashing like we do for the "move patch to
index" command. However, in this case we rather simply stage the affected files
(after asking for confirmation). This has a few advantages:

- it only changes the staging state of those files that are contained in the
patch (whereas auto-stashing always changes all files to unstaged)
- it doesn't unnecessarily show a confirmation if none of the modified files are
affected by the patch
- if the patch conflicts with the modified files, the conflicts were "backwards"
("ours" was the patch, "theirs" the modified file); it is more logical if "ours"
is the current state of the file, and "theirs" is the patch.

It's a little unfortunate that the behavior isn't exactly the same as for "move
patch to index", but for that one we do need the auto-stash because of the
rebase that runs behind the scenes.
2025-07-02 16:19:06 +02:00
Stefan Haller c440a208a6 Add tests for applying a patch when there's a modified file
The tests show that this currently fails with the confusing error message "does
not match index", regardless of whether the patch conflicts with the
modifications or not. We'll improve this in the next commit.

I don't bother adding tests for reverting a patch, as the code is basically the
same as for apply.
2025-07-02 16:19:06 +02:00
Stefan Haller 32bd9e6029 Drop stash when successfully unstashing files after moving patch to index 2025-07-02 16:19:06 +02:00
Stefan Haller 823aa640b9 Add test for moving patch to index when there's a modified file
This is functionality that works already, we only add the test for more complete
test coverage. However, there's a detail problem, and the test demonstrates
this: we keep the stash even if there was no conflict. We'll fix this next.
2025-07-02 16:19:06 +02:00
Stefan Haller 00d043d743 Cleanup: implement AllFilesInPatch using lo.Keys
Curiously, the function was never called so far, but we're going to use it later
in this branch.
2025-07-02 16:19:06 +02:00
Stefan HallerandGitHub eebc39d3e9 Show stash name for selected stash (#4673)
- **PR Description**

In the Stash panel, show information about the selected stash above the
diff of the stash in the main view. This is useful for stash entries
with very long names that are not fully visible in the Stash panel.

Fixes #4662.
2025-07-02 16:18:11 +02:00
Stefan Haller 92c9eb614f Show stash title in main view for selected stash entry 2025-07-02 16:15:19 +02:00
Stefan Haller ef16867ff1 Cleanup: add NewRunPtyTaskWithPrefix funxtion instead of setting Prefix manually
This is consistent with NewRunCommandTaskWithPrefix.
2025-07-02 16:15:19 +02:00
Stefan HallerandGitHub edcfce22f0 Change Refresh to not return an error (#4680)
- **PR Description**

Refresh is one of those functions that shouldn't require error handling
(similar to triggering a redraw of the UI, see
https://github.com/jesseduffield/lazygit/issues/3887).
2025-07-02 16:14:11 +02:00
Stefan Haller c87661dbee Use async refresh rather than manual OnWorker call
This is exactly what async refresh is for.
2025-07-02 16:10:04 +02:00
Stefan Haller d82852a909 Change Refresh to not return an error
Refresh is one of those functions that shouldn't require error handling (similar
to triggering a redraw of the UI, see
https://github.com/jesseduffield/lazygit/issues/3887).

As far as I see, the only reason why Refresh can currently return an error is
that the Then function returns one. The actual refresh errors, e.g. from the git
calls that are made to fetch data, are already logged and swallowed. Most of the
Then functions do only UI stuff such as selecting a list item, and always return
nil; there's only one that can return an error (updating the rebase todo file in
LocalCommitsController.startInteractiveRebaseWithEdit); it's not a critical
error if this fails, it is only used for setting rebase todo items to "edit"
when you start an interactive rebase by pressing 'e' on a range selection of
commits. We simply log this error instead of returning it.
2025-07-02 16:09:42 +02:00
Stefan HallerandGitHub 2b1f150129 Some code cleanups to the "discard file changes from commit" feature (#4679)
- **PR Description**

I ran into these issues while reading the code.
2025-07-02 16:02:58 +02:00
Stefan Haller 5be97c6145 Remove another unnecessary refresh
This was added after this PR comment:
https://github.com/jesseduffield/lazygit/pull/3276#discussion_r1469077611

> Can we do a refresh after this reset so that the screen shows that the patch
> has been cancelled? That way, if we cancel on the next popup, the screen will
> be in a valid state.

I don't understand what "cancel on the next popup" means; there is no further
popup after this code.
2025-07-02 15:58:03 +02:00
Stefan Haller 80e20417a8 Remove unnecessary refresh
CheckMergeOrRebase already calls Refresh.
2025-07-02 15:58:03 +02:00
Stefan Haller ee62878e6b Cleanup: remove pointless error handling
ForEachFile can't possibly return an error if the passed function doesn't return
one.
2025-07-02 15:47:48 +02:00
Stefan HallerandGitHub 2a5970265d Fix formatting of a keyboard shortcut in the README.md (#4678)
- **PR Description**

This will format the `z` keyboard shortcut reference in this text in the
same way as all other keyboard shortcuts in the README.md file.
2025-07-02 15:28:48 +02:00
Stefan HallerandGitHub 36388e58b9 Update linter (#4671)
- Update the golangci-lint configuration to use the latest version
(2.2.1)
- Enable a few more linter checks
- Improve the VS Code configuration so that we don't get spurious linter
warnings that wouldn't also show up on CI
- Provide a way to run the exact same golangci-lint version locally that
we use on CI. This is useful in case the globally installed version is a
newer one which emits more warnings.
2025-07-01 11:08:24 +02:00
Stefan Haller ca05a2ccea Enable revive linter, and fix a bunch of warnings
I took the set of enabled checks from revive's recommended configuration [1],
and removed some that I didn't like. There might be other useful checks in
revive that we might want to enable, but this is a nice improvement already.

The bulk of the changes here are removing unnecessary else statements after
returns, but there are a few others too.

[1] https://github.com/mgechev/revive?tab=readme-ov-file#recommended-configuration
2025-06-30 19:13:20 +02:00
Stefan Haller 7aa426fa71 Enable errorlint linter, and fix warnings 2025-06-30 18:30:11 +02:00
Stefan Haller 0471dbaa84 Enable intrange linter, and fix warnings 2025-06-30 18:30:11 +02:00
Stefan Haller 1e92d8b7f3 Enable nolintlint linter, and fix warnings 2025-06-30 18:30:11 +02:00
Stefan Haller d9e299c1df Update VS Code settings to enable staticcheck linter
... and configure it to run the same checks as golangci-lint.

It may seem redundant to have two linter checks enabled; however, there are
reasons to have both. golangci-lint is what we are running on CI, and it has a
lot more linters than gopls, so we want to run it locally too to get the same
coverage. The linter that is built into gopls is only staticcheck, so that's
redundant; but it has the advantage that the warnings appear a bit faster
(golangci-lint runs only on save, and with a bit of delay), and in particular it
provides quick fixes for some of the checks, which is quite convenient.
2025-06-30 18:30:11 +02:00
Stefan Haller 9b54dc0b28 Update VS Code settings to use golangci-lint v2
We configure it to call the same binary that the new lint script also uses (see
beginning of the branch).
2025-06-30 18:30:11 +02:00
Stefan Haller c4de94cff0 Update .golangci.yml to use version 2
The config file was migrated using `golangci-lint migrate`, and then edited by
hand to disable a few checks that we don't want.
2025-06-30 18:30:11 +02:00
Stefan Haller 92093ce56a Fix warning QF1003: could use tagged switch 2025-06-30 18:30:11 +02:00
Stefan Haller c7d0aaa786 Fix warning QF1004: could use strings.ReplaceAll instead 2025-06-30 18:30:11 +02:00
Stefan Haller 4604227238 Make stashEntryFromLine a free-standing function
It doesn't use the receiver at all, so doesn't have to be a method.

This fixes ST1016: methods on the same type should have the same receiver name.
2025-06-30 18:30:11 +02:00
Stefan Haller b7aecf5f17 Fix warning ST1016: methods on the same type should have the same receiver name 2025-06-30 18:30:11 +02:00
Stefan Haller 8c574f888c Fix warning ST1016: methods on the same type should have the same receiver name
Most methods use gui as a receiver name (120 of them), so switch the few that
use self over to that too.
2025-06-30 18:30:11 +02:00
Stefan Haller 7ebf5fff0f Provide a script to lint the whole working copy, and update make lint to use it
The script expects a golangci-lint binary in .bin; this makes it possible to
install the exact same version that also runs on CI.
2025-06-30 18:30:11 +02:00
Stefan HallerandGitHub 4439531906 Show annotation information for selected tag (#4663)
- **PR Description**

In the Tags panel, show information about the selected tag above the
commit log. This is mostly useful for annotated tags.

Fixes #4659.
2025-06-30 16:14:20 +02:00
Stefan Haller e5b09f34e0 Show tag information for selected tag 2025-06-30 16:12:33 +02:00
Stefan Haller b12b1040c3 Add IsAnnotated field to models.Tag struct 2025-06-30 16:12:33 +02:00
Stefan HallerandGitHub 718cbdb48c Fix branch head icon appearing at head commit when a remote or tag exists with the same name as the current branch (#4669)
- **PR Description**

Fix the problem that if the `rebase.updateRefs` git config is on, a
branch icon would appear in the commits list for the head commit as soon
as a remote or tag exists whose name is the same as the name of the
current branch.
2025-06-30 16:12:09 +02:00
Stefan Haller 03abdfcfe2 Fix the CurrentBranchName function
The function would return "head/branchname" when there was either a tag or a
remote with the same name.

While fixing this we slightly change the semantic of the function (and of
determineCheckedOutBranchName, which calls it): for a detached head it now
returns an empty string rather than the commit hash. I actually think this is
better.
2025-06-30 16:08:03 +02:00
Stefan Haller f95ac6780f Cleanup: turn around error condition
It is a common go convention for the "happy path" to be as little indented as
possible.
2025-06-30 16:08:03 +02:00
Stefan Haller 61815c10e7 Add a test showing undesired branch icon at head commit
The icon will appear when there's a tag with the same name as the current branch
(that's what we're testing here), or even when there's a remote with the same
name. I'm not adding a test for this latter case, but this was actually how I
discovered the issue.
2025-06-30 16:08:03 +02:00
Stefan HallerandGitHub 7a8937279a Bump github.com/cloudflare/circl from 1.6.0 to 1.6.1 (#4633)
Bumps [github.com/cloudflare/circl](https://github.com/cloudflare/circl)
from 1.6.0 to 1.6.1.
2025-06-30 16:07:34 +02:00
Stefan HallerandGitHub 75ee875194 Show GPG error before entering commit editor when rewording non-latest commits (#4660)
- **PR Description**

When GPG signing is enabled but overrideGpg is false, attempting to
reword a non-latest commit would show the "Feature not vailable for
users using GPG" error only after the user had already entered the
commit message.

Now the error is displayed immediately when attempting to start the
reword operation, before opening the editor.

Closes #4611
2025-06-30 08:40:42 +02:00
Stefan HallerandGitHub ef6f96bda3 Add credential prompts for PKCS11-based SSH keys (#4646)
- **PR Description**
Similar to #2239, add credential prompts for PKCS11-based SSH keys.
OpenSSH code reference is
[here](https://github.com/openssh/openssh-portable/blob/2827b6ac304ded8f99e8fbc12e7299133fadb2c2/ssh-pkcs11.c#L263).
2025-06-20 08:26:01 +02:00
Stefan HallerandGitHub 80887f5791 Fix DEFAULT_REMOTE_ICON character code (#4653)
Unicode characters with code longer than 4 digits should be written as
`\Uffffffff` (8 digits)

Fixes #4652
2025-06-20 08:22:15 +02:00
Stefan HallerandGitHub 159efdef9f Fix moving a custom patch from the very first commit of the history to a later commit (#4631)
- **PR Description**

Moving a custom patch from the very first commit of the history to a
later commit would crash with an index-out-of-range error.

I double-checked that all other callers of
PrepareInteractiveRebaseCommand already call getBaseHashOrRoot, so this
was the only one that was broken.

I decided not to add a test for this as the scenario is not a very
common one.

Fixes #4624.
2025-06-19 18:46:28 +02:00
Stefan Haller 206283d1f7 Fix moving a custom patch from the very first commit of the history to a later commit
This would crash with an index-out-of-range error.

I double-checked that all other callers of PrepareInteractiveRebaseCommand
already call getBaseHashOrRoot, so this was the only one that was broken.

I decided not to add a test for this as the scenario is not a very common one.
2025-06-19 18:43:17 +02:00
Stefan HallerandGitHub ec0f4d242e Instantiate mutexes by value (#4632)
- **PR Description**

Here's a minor cleanup: instantiate mutexes by value so that they don't
have to be initialized explicitly. It is always preferable for structs
to have a valid zero value, and this is one small step in that
direction.

I read this recommendation in the [Uber style
guide](https://github.com/uber-go/guide/blob/master/style.md#zero-value-mutexes-are-valid),
and it makes a lot of sense to me. I find most of the rest of this style
guide to be a very good read, too.
2025-06-19 18:42:56 +02:00
Stefan Haller fd270768e8 Instantiate other mutexes by value
Like in the previous commit, this is preferred because the fields don't need to
be initialized this way.
2025-06-19 18:39:46 +02:00
Stefan Haller 5ee5d42511 Instantiate Mutexes's fields by value
Instead, pass the entire Mutexes struct by pointer to controllers.

This is better because Mutexes now has a zero value and doesn't need to be
initialized.
2025-06-19 18:39:46 +02:00
Stefan HallerandGitHub 4c92ffda60 Add bold style for border (#4644)
- **PR Description**

bold border looks great and makes it easy to notice the color change
2025-06-15 18:23:47 +02:00
Stefan HallerandGitHub fb2c5ea8b6 Fix stash operations when branch named 'stash' exists (#4641)
- **PR Description**

Pretty basic fix, didn't seem to have any complications. I basically
just grepped for `stash{` and all of the references seemed like they
could benefit from the addition. I only added the refs/ prefix to the
FullRefName() method to align with other similar methods, and to make
this change not impact any user facing modals. I added one integration
test for the super obvious failure behavior. I didn't feel that it was
worth it to create duplicate integration tests for the other behaviors
of drop, apply, pop, etc. I did manually test them though. If
interested, I could add the creation of the `stash` branch to all the
existing tests of stash behavior, just to prove they continue to work
under those conditions. I just didn't do that on the first pass cause I
could see how that could take away from the core behavior the tests are
trying to demonstrate.

Fixes: https://github.com/jesseduffield/lazygit/issues/4634
2025-06-15 16:17:26 +02:00
Stefan HallerandGitHub aa23a6e2b5 Add option to disable warning when amending last commit (#4640)
- **PR Description**
Add an option in the User Config to disable the warning message when
amending the last commit.

Fixes #4636
2025-06-13 16:47:58 +02:00
Stefan HallerandGitHub aa331e52b8 Fix assigning custom key to pullFiles command in the Commits panel (#4617)
- **PR Description**

Improve the dispatching of key bindings so that remapping "pullFiles" to
a different key works correctly in the Commits panel.

Fixes #4614.
2025-06-05 13:24:34 +02:00
Stefan Haller c752f3529b Remove the pick vs. pull hack
Previously we would call pullFiles() from the pick() handler if we were not in a
rebase, assuming that the default keybinding for both is "p". This needn't be
the case of course, if the user has remapped one or the other.

The consequence of this was that swapping the keybindings for "pullFiles" and
"pushFiles" would work in all panels except the Commits panel (unless "pick" was
also remapped in the same way).

Fix this by using the new AllowFurtherDispatching mechanism of DisabledReasons
to pass the keybinding on to the next handler.
2025-06-05 13:20:39 +02:00
Stefan Haller 3e26be9845 Optionally pass disabled commands on to next handler
If a DisabledReason has its AllowFurtherDispatching flag set, it is returned as
a ErrKeybindingNotHandled error, instead of shown as a toast right away. This
allows gocui to continue to dispatch the keybinding, and we can unwrap the error
at the other end (in our global ErrorHandler) and display it then.

This allows having keybindings for the same key at the local and global levels,
and they will continue to be dispatched even if the first one returns a
DisabledReason. It is opt-in, so we only use it for cases where we know that a
local and a global handler share the same (default) keybinding.
2025-06-05 13:20:38 +02:00
Stefan Haller 37b118f4fb Cleanup: restructure code for clarity
There was no reason to declare a variable for disabledReason, assign it inside
the "if binding.GetDisabledReason != nil" statement, and then check its value
again after that if statement. Move all that code inside the first if statement
to make the control flow easier to understand.
2025-06-05 13:20:38 +02:00
Stefan Haller 9e64f7dd66 Bump gocui and adapt lazygit code
Adaptions are for this gocui commit:

Cleanup: remove Is* error functions

- Use errors.Is instead of quality comparisons. This is better because it
  matches wrapped errors as well, which we will need later in this branch.
- Inline the errors.Is calls at the call sites. This is idiomatic go, we don't
  need helper functions for this.

See https://go.dev/blog/go1.13-errors for more about this.
2025-06-05 13:20:38 +02:00
Stefan HallerandGitHub ac0c3db472 Fix wrong inactive highlight when switching between repos (#4621)
- **PR Description**

When switching between repos, each repo might have a different focused
panel; in this case, the previously focused panel would show the
"inactive" highlight. By default this is only bold text, so it's barely
noticeable, but it becomes more pronounced when setting e.g.

```yml
gui:
  theme:
    inactiveViewSelectedLineBgColor:
      - "#666666"
```

I noticed this especially when entering or leaving submodules; for
example, enter a submodule by pressing enter in the Files panel, then
switch to the Commits panel in the submodule, then press Esc to go back
to the parent repo. This would put the focus back into the Files panel,
but keep the inactive highlight in the Commits panel.
2025-06-05 13:00:54 +02:00
Stefan Haller f185e1a5e3 Fix wrong inactive highlight when switching between repos
When switching between repos, each repo might have a different focused panel; in
this case, the previously focused panel would show the "inactive" highlight. By
default this is only bold text, so it's barely noticeable, but it becomes more
pronounced when setting e.g.

gui:
  theme:
    inactiveViewSelectedLineBgColor:
      - "#666666"

I noticed this especially when entering or leaving submodules; for example,
enter a submodule by pressing enter in the Files panel, then switch to the
Commits panel in the submodule, then press Esc to go back to the parent repo.
This would put the focus back into the Files panel, but keep the inactive
highlight in the Commits panel.
2025-06-05 12:58:38 +02:00
Stefan HallerandGitHub ac7de7e8de Fix resetting to a branch when a tag shares the same name, or vice versa (#4571)
- **PR Description**

Allows the reset menu to have a different name that is displayed, and a
fully qualified name that git will unambiguously know what it refers
about. We could totally squash this back down to 1 input, and display to
the user the _precise_ full ref name that we are resetting to, but I
think the context they are in (branches tab versus tag tab), means that
we don't need to do that, and can continue to just show the branch name
and the tag name to the end users.

Fixes https://github.com/jesseduffield/lazygit/issues/4569
2025-06-04 20:48:32 +02:00
Stefan HallerandGitHub 36de219eb7 Show default option when prompting to create a new git repo (#4596) 2025-06-04 08:25:53 +02:00
Stefan HallerandGitHub 1e5d104524 Improve PR template wrt release notes (#4607)
Mention in the PR template that PR titles will be used in release notes.
This came up in #4571.
2025-06-01 14:38:09 +02:00
Stefan Haller 946f5f130c Make PR template mention that PR titles will be used in release notes 2025-06-01 14:34:12 +02:00
Stefan HallerandGitHub a8c73f1ff2 Replace literal with ConfigFilename constant (#4613)
A tiny clean-up where I assume it is a good idea to re-use the common
specification of the `"config.yml"` name.
2025-05-31 17:34:06 +02:00
Stefan HallerandGitHub 8280fdedb7 Use branchPrefix when moving commits to new branch (#4604)
- **PR Description**

When pressing N to move new commits to a new branch we get greeted with
an empty prompt, this PR makes it so we fill the empty prompt with a
suggestion taken from branchPrefix, similar to the good old create a new
branch.
2025-05-29 22:42:37 +02:00
Stefan HallerandGitHub 5b4d009f55 Fix branch selection jumping back on background fetch (#4597)
- **PR Description**

When refreshing the branches list, we have code to keep the same branch
selected even when the refresh changes the sort order; this code
remembers the selected branch before the refresh, and then tries to
select it again afterwards (looking it up by name) if it is still there.

However, we stored the previously selected branch too early, before even
obtaining the branches list; if the user moved the selection between
that point and the end of the refresh, it would jump back. Fix this by
remembering the previous selection only at the last moment, right before
assigning the new branches slice.

We still have a race condition here between the UI code that manages the
selection as the user presses arrow keys, and the background thread
doing the refresh that reads and restores the selection; however, the
race was there before, and we make it neither better nor worse with this
PR. It doesn't seem to be a problem in practice.

Fixes #4116.
2025-05-29 14:45:09 +02:00
Stefan Haller fce4816a0d Fix branch selection jumping back on background fetch
When refreshing the branches list, we have code to keep the same branch selected
even when the refresh changes the sort order; this code remembers the selected
branch before the refresh, and then tries to select it again afterwards (looking
it up by name) if it is still there.

However, we stored the previously selected branch too early, before even
obtaining the branches list; if the user moved the selection between that point
and the end of the refresh, it would jump back. Fix this by remembering the
previous selection only at the last moment, right before assigning the new
branches slice.

We still have a race condition here between the UI code that manages the
selection as the user presses arrow keys, and the background thread doing the
refresh that reads and restores the selection; however, the race was there
before, and we make it neither better nor worse with this PR. It doesn't seem to
be a problem in practice.
2025-05-29 14:41:59 +02:00
Stefan HallerandGitHub 676b5c2287 Kill background fetch when it requests a passphrase (#4588)
Previously we would enter a newline at the password prompt, which would
cause the fetch to fail. The problem with this was that if you have many
remotes, the fetch would sometimes hang for some reason; I don't totally
understand how that happened, but I guess the many ssh processes
requesting passwords would somehow interfere with each other. Avoid this
by simply killing the git fetch process the moment it requests the first
password.
2025-05-29 14:39:39 +02:00
Stefan Haller d5bd30474c Kill background fetch when it requests a passphrase
Previously we would enter a newline at the password prompt, which would cause
the fetch to fail. The problem with this was that if you have many remotes, the
fetch would sometimes hang for some reason; I don't totally understand how that
happened, but I guess the many ssh processes requesting passwords would somehow
interfere with each other. Avoid this by simply killing the git fetch process
the moment it requests the first password.
2025-05-29 14:36:01 +02:00
Stefan Haller 75a8c0c73e Pass cmdObj instead of task to processOutput
This is a preparation for the next commit, where we will need more from the
cmdObj in processOutput.
2025-05-29 14:36:01 +02:00
Stefan HallerandGitHub c4bfdaeaf3 Fix selecting large hunks, and fix problems editing very long commit descriptions (#4589)
See https://github.com/jesseduffield/gocui/pull/80 for details.

Fixes #4470.
2025-05-29 14:35:35 +02:00
Stefan Haller 5dbd91038a Bump gocui
See https://github.com/jesseduffield/gocui/pull/80.

This fixes selecting hunks in the staging view that are longer than the screen.
2025-05-29 14:33:17 +02:00
Stefan HallerandGitHub 21b8b2827e Add user config for hiding the root item in the file tree (#4593)
- **PR Description**

In #4346 we added a `/` root item in the Files and CommitFiles panels
whenever there is more than one top-level item. We made it
unconditional, but I promised to add a config as soon as users ask for
being able to disable it. For a while I was able to convince users who
asked for it that it is useful and they don't want to turn it off, but
now there's a [stronger
request](https://github.com/jesseduffield/lazygit/discussions/4590#discussioncomment-13254924)
from someone who refuses to upgrade to the current version, and we don't
want that.

So, add a config option `gui.showRootItemInFileTree` that is true by
default.
2025-05-26 21:18:19 +02:00
Stefan Haller 3cff48437e Add user config gui.addRootItemInFileTree 2025-05-24 18:17:25 +02:00
Stefan Haller ffb8586795 Pass common.Common to file trees instead of just the Log
We will need a user config in the file tree in the next commit, and passing the
entire common is the easiest way to do that while ensuring hot-reloading when
users change the config while lazygit is running.
2025-05-24 17:56:43 +02:00
Stefan Haller 2a8ef71e8f Use PTY also with credentialStrategy=FAIL
This is a regression introduced with a199ed1396c; it is important to use a PTY
even with credentialStrategy=FAIL, otherwise the fetch command will spew the
credentials request into the UI and then hang.

This fixes the problem that background fetching makes lazygit hang when the
fetch request needs to prompt for a passphrase. For Mac users who use the
keychain to store their ssh passphrases, this can happen when lazygit is running
while the machine goes to sleep, because macOS looks the keychain in that case.
2025-05-23 11:34:57 +02:00
Stefan HallerandGitHub 6705428a8d Fix crash when clicking in the status view (#4567)
- **PR Description**

The status view is not supposed to be focusable right now. (This might
change soon, but for now it isn't.) Pressing '0' on it does nothing.

However, clicking on it would still focus it, because the click handler
in MainViewController assumed that when the clicked view doesn't have
the focus, then its "other" view must have, and we just want to toggle
the focus between the two (like when pressing tab). It didn't take the
possibility into account that the current side panel isn't focusable at
all; if it was, then its SwitchToFocusedMainViewController would have
handled the click.

To fix this, check if the "other" view has the focus before handling the
click, and do nothing otherwise.

This also fixes clicking in the main views of the Worktrees or
Submodules tabs, or any other tabs whose main views are not focusable.

Fixes #4566.
2025-05-22 14:41:04 +02:00
Stefan Haller bbd17abc43 Add ContextMgr.NextInStack and use it to access side panel of focused main view
This way we don't have to abuse the parent context mechanism, which isn't meant
for this purpose.
2025-05-22 14:38:40 +02:00
Stefan Haller 12ed50464b Cleanup: pass target context to focusMainView directly
It's a bit silly to pass a window name and then call a function to get the
corresponding context, when we can simply pass the context directly.
2025-05-22 14:38:40 +02:00