1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-23 12:18:51 +02:00

735 Commits

Author SHA1 Message Date
Kevin Radloff
be7583dd40 Update to go 1.24 2025-03-08 14:53:54 -05:00
Stefan Haller
e6d6ed4f9a Use Rewording instead of Committing when rewording the head commit
Now that we have this status, let's use it for the head case too, for
consistency.
2025-03-06 08:15:18 +01:00
Stefan Haller
c18d8af9f4 Use a WithWaitingStatus for rewording a non-head commit
Rewording a commit at the beginning of a long branch can take very long;
without this change, the commit message panel would stay visible with a blinking
cursor during that time, which is very confusing.

This has the slight downside that it will say "Rebasing" in the lower right
corner until the operation is done; but we already have this problem when doing
custom patch operations, or dropping changes from a commit, so it's not new, and
we can think about how to fix all these another time.
2025-03-06 08:15:18 +01:00
Stefan Haller
eda65cbade Avoid double Refresh when rewording the head commit
WithGpgHandling already does an async refresh when done, so there's no need to
do one here for the case of amending the head commit. On top of that,
WithGpgHandling uses WithWaitingStatus and works in the background, so the
Refresh here would come too early anyway.
2025-03-06 08:15:18 +01:00
Stefan Haller
41a7afb105 Don't call OnCommitSuccess in handleReword
All this does is clear the preserved commit message; however, we open the commit
message panel with PreserveMessage: false when rewording, so this is not
necessary.
2025-03-06 08:15:18 +01:00
Stefan Haller
44097384d3 Remove unnecessary type arguments
I'm getting warnings in my editor about these, probably because of an updated
gopls again.
2025-03-03 21:24:49 +01:00
Chris McDonnell
9d0740427e Change side panel width calculation to work for larger numbers
This technically is a breaking change for some existing numbers,
but it stays the same for default case, and isn't much different for
others
2025-02-24 07:36:47 +11:00
Chris McDonnell
b766ff9c83 Disable global keybinds while popups are active 2025-02-23 08:44:48 +01:00
Stefan Haller
3e11e34181 Fix race condition with reselecting the focused branch and rendering
In ff4ae4a544 we changed the order of the calls to render before selecting the
branch. This was done only to save an extra call to ReApplyFilter, which is done
by refreshView; I claimed that the order of refreshView vs. SetSelectedLineIdx
doesn't matter here. I guess I was wrong about that, it makes the integration
test custom_commands/suggestions_preset.go flaky. To fix this, put the
refreshView call back to where it was (after the SetSelectedLineIdx call), and
instead insert an extra call to ReApplyFilter where necessary to fix the bug
that ff4ae4a544 was trying to fix.
2025-02-22 10:07:27 +01:00
Stefan Haller
e5137b86cf Add a tabWidth parameter to WrapViewLinesToWidth to match gocui 2025-02-20 09:13:56 +01:00
Stefan Haller
c9196812a2 Add a "Copy to clipboard" menu to the Commit Files panel
This is very similar to the same menu in the Files panel, except that it works
on whatever diff is currently shown in the main view, including range diffs
either in diffing mode (shift-W), or from a range selection of commits.
2025-02-19 18:50:12 +01:00
Chris McDonnell
2fa4ee2cac feat: Support multiple commit prefixes
This implementation, unlike that proposed in https://github.com/jesseduffield/lazygit/pull/4253
keeps the yaml schema easy, and does a migration from the single
elements to a sequence of elements.
2025-02-17 19:58:31 +01:00
Chris McDonnell
ab23539c0c Add option to copy commit message body 2025-02-17 18:43:39 +01:00
Stefan Haller
ba6cfc1f85 Handle pasting multi-line commit messages
When pasting a multi-line commit message into the subject field of the commit
editor, we would interpret the first newline as the confirmation for closing the
editor, and then all remaining characters as whatever command they are bound to,
resulting in executing all sorts of arbitrary commands.

Now we recognize this being a paste, and interpret the first newline as moving
to the description.

Also, prevent tabs in the pasted content from switching to the respective other
panel; simply insert four spaces instead, which should be good enough for the
leading indentation in pasted code snippets, for example.
2025-02-10 13:40:25 +01:00
Stefan Haller
e987d4b519 Swap position of checkout-commit and checkout-branch menu items
Jesse's comment from https://github.com/jesseduffield/lazygit/issues/4237:

We recently added a new option to check out a commit's branch from within the
commits, reflog, and sub-commits panels:

https://github.com/user-attachments/assets/0a5cf3f2-6803-4709-ae5a-e4addc061012

After using it for some time, I find it annoying that the default option has
changed. I rarely find myself wanting to check out a branch from the commits
panel, and it's rarer still to want to check out a branch from the reflog and
sub-commits panel. Although there may be use cases for this, it is jarring that
something you can always do (checkout the commit) is harder to do than something
that you can sometimes do (checkout the branch).

We've also had a user complain (see
https://github.com/jesseduffield/lazygit/pull/4117) about their muscle-memory
being broken by the recent change, and I have also fallen victim to this. I
don't think that the new branch checkout option is sufficiently useful to
dislodge the existing keybinding, so let's swap them.
2025-02-10 13:35:01 +01:00
Stefan Haller
ff4ae4a544 Fix possible crash when deleting a branch while filtering is active
The code that tries to reselect the same branch again uses GetItems, which in
case of filtering is the filtered list. After replacing the branches slice with
a new one, the filtered list is no longer up to date, so we must reapply the
filter before working with it. It so happens that refreshView does that, so
simply call that before setting the selection again; I don't think the order
matters in this case. Otherwise we'd have to insert another call to
ReApplyFilter before the call to GetItems, which we can avoid this way.

Note that this doesn't actually make anything work better in the case of
deleting a branch, since we can't reselect the deleted branch anyway of course.
But it avoids a possible crash if the branch that was deleted was the last one
in the unfiltered list.
2025-02-07 09:34:25 +01:00
AzraelSec
a32be7e9fa Implement reboot-resistant commit message persistence 2025-02-07 09:28:27 +01:00
Stefan Haller
aad2622278 Show filter state in top right corner of Files panel frame
This includes the "only conflicting" status that the user can't switch to
themselves. We display it anyway to give a hint that files are being filtered,
and to let them know that they can turn the filter off if they want to.
2025-02-07 09:24:24 +01:00
Stefan Haller
2f4cedd025 Show current files filter as radio buttons
I renamed the "Reset filter" item to "No filter" to make it look more like a
state than an action, so that it fits the radio button concept better.

When there are conflicts and we set the filter to show only conflicting files,
then none of the radio buttons light up, which is slightly strange. I guess it's
ok though.
2025-02-07 09:24:24 +01:00
Stefan Haller
e883f74f3c Allow user to switch filter when showing only conflicts
We don't need to maintain additional state to allow this; all we need to do is
take over the filter only when the number of conflicting files goes from zero to
non-zero, rather than every time it is non-zero.

The only problem is that we don't allow users to go back to showing only
conflicted files, but that's just because we don't have that as an entry in the
menu. And I don't think it's a problem.
2025-02-07 09:24:24 +01:00
Jesse Duffield
7e85cdd027 Allow user to filter the files view to only show untracked files
This handles the situation where the user's own config says to not show
untracked files, as is often the case with bare repos managing a user's
dotfiles.
2025-02-07 09:04:55 +11:00
Brandon
02ca07a9be Fix incorrect stash diff after rename 2025-02-06 09:55:26 +01:00
Stefan Haller
437daf2f74 Disable staging and unstaging lines or hunks when the diff context size is 0
Git diff and patch doesn't work reliably with a context size of 0, so disable it
in this case (and discarding changes as well). Magit does the same, see
https://github.com/magit/magit/issues/4222.

Staging entire files by pressing space in the Files panel is still possible, of
course.
2025-02-05 16:07:22 +01:00
Stefan Haller
0a78d0016e Show confirmation menu when trying to amend changes while there are conflicts 2025-01-30 08:53:34 +01:00
Stefan Haller
e48e7a2ebc Extract the inner part of WithWaitingStatus as a synchronous variant of it
This is the same as WithWaitingStatus but without the implicit OnWorker, for
those who are on a background thread already.
2025-01-30 08:49:58 +01:00
Anvar Umuraliev
7db8fb8e9c Add option to delete local and remote tag 2025-01-30 09:05:17 +11:00
Bruno Jesus
698f9287d4 Rename NoTags to CommitHasNoTags 2025-01-28 23:11:06 +00:00
Bruno Jesus
333802fffc Copy Tags to clipboard
Add an option to copy tag(s) to the clipboard.

Works on both the Tags and Commits sections.
2025-01-27 21:53:13 +00:00
Stefan Haller
0864affc8f Fix checking out a different branch while pushing a branch for the first time
When pushing a branch that didn't have an upstream yet, we use the command line

  git push --set-upstream origin HEAD:branch-name

The HEAD: part of this is too unspecific; when checking out a different branch
while the push is still running, then git will set the upstream branch on the
newly checked out branch, not the branch that was being pushed. This might be
considered a bug in git; you might expect that it resolves HEAD at the beginning
of the operation, and uses the result at the end.

But we can easily work around this by explicitly supplying the real branch name
instead of HEAD.
2025-01-26 10:22:19 +01:00
Stefan Haller
20d0b4316d Only avoid the blank line at end of view if view is not editable
For editable views it is important to actually show the blank line so that we
can put the cursor there for typing.

This fixes problems with adding blank lines at the end of longer commit
messages.
2025-01-20 17:52:53 +01:00
Gabriel Lanata
4065175a58 Improve undo action to restore files upon undoing a commit 2025-01-18 00:07:15 +11:00
Mauricio Trajano
7bea41534b Collapse/expand all files in tree
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2025-01-13 21:13:11 +01:00
Jesse Duffield
28d10c26a4 Standardise on 'screen mode' name
We had some conflicting names so we're standardising on screen mode
2025-01-11 14:25:48 +11:00
Brandon
c44231a7d7 Add number of commits to cherry-pick confirmation prompt 2025-01-08 21:08:42 -08:00
Stefan Haller
64cd7cd9f6 Adjust line number for working copy when editing a line
There are two ways to jump to the editor on a specific line: pressing `e` in the
staging or patch building panels, or clicking on a hyperlink in a delta diff. In
both cases, this works perfectly in the unstaged changes view, but in other
views (either staged changes, or an older commit) it can often jump to the wrong
line; this happens when there are further changes to the file being viewed in
later commits or in unstaged changes.

This commit fixes this so that you end up on the right line in these cases.
2025-01-07 17:46:51 +01:00
Stefan Haller
eaaf123238 Combine GetPathDiff and GetAllDiff into one command (GetDiff)
This makes it more reusable for other purposes.
2025-01-07 17:46:51 +01:00
Stefan Haller
53b1e12110 Cleanup: use the upstream local variable consistently
We need to move it closer to the beginning of the method to use it everywhere.
2025-01-04 15:48:26 +01:00
Stefan Haller
009062534e Fix resetting or rebasing a branch to its upstream when the upstream branch name is different 2025-01-04 15:48:26 +01:00
Stefan Haller
bf9339557e Show the <a-enter> keybinding at bottom of commit description view
It was hard to discover, this should make it more obvious.
2025-01-03 10:16:29 +01:00
Stefan Haller
928e76a82f Disable KeybindingsMenu using a DisabledReason when a panel is open
This hides it from the options map at the bottom of the screen.
2025-01-03 10:09:42 +01:00
Nathan Baulch
508cdb40a8 Fix typos 2025-01-03 10:50:36 +11:00
John Mutuma
fc78082e81 Formatting the file with gofumpt 2025-01-02 16:52:24 +11:00
John Mutuma
e1c18226bf Add worktree option to fast forwarding operation 2025-01-02 16:52:24 +11:00
Sebastian Flügge
f4c8287143 Allow to switch branches in Commit View
When the user checks out a commit which has a local branch ref attached
to it, they can select between checking out the branch or checking out
the commit as detached head.
2025-01-01 14:55:12 +01:00
Stefan Haller
3a30211099 Don't preserve commit message when it's unchanged from initial message
Sometimes we populate the commit message panel with a pre-created commit
message. The two cases where this happens is:
- you type `w` to commit, in which case we put the skipHookPrefix in the subject
- you have a commitPrefix pattern, in which case we match it against the branch
  name and populate the subject with the replacement string if it matches

In either case, if you have a preserved commit message, we use that.

Now, when you use either of these and then cancel, we preserve that initial,
unchanged message and reuse it the next time you commit. This has two problems:
it strips spaces, which is a problem for the commitPrefix patterns, which often
end with a space. And also, when you change your config to experiment with
commitPrefix patterns, the change seemingly doesn't take effect, which can be
very confusing.

To fix both of these problems, only preserve the commit message when it is not
identical to the initial message.
2024-12-23 12:28:52 +01:00
Stefan Haller
15288b7bf4 Add user config to enable line wrapping in the staging view
It is enabled by default, because I think it's often helpful, and rarely in the
way. I bet most user won't even notice.
2024-12-23 12:24:09 +01:00
Stefan Haller
5213a9de32 Handle wrapped lines in patch explorer state
So far, lines in the view corresponded 1:1 to lines in the patch. Once we turn
on wrapping for the staging view (which we don't do yet), this is no longer
true, so we need to convert from view lines to patch lines or vice versa all
over the place.
2024-12-23 12:24:09 +01:00
Stefan Haller
b7444b9a49 Return arrays with line indices from WrapViewLinesToWidth
This makes it easy to convert an original line index to a wrapped line index, or
vice versa.
2024-12-23 12:24:09 +01:00
Stefan Haller
1f2cb35cc9 Refactor: move wrapMessageToWidth to utils/lines.go
to make it more generally usable by clients other than ConfirmationHelper, which
we will do later in this branch. Rename it to WrapViewLinesToWidth while we're
at it.

Add tests; in particular, add a sanity check that we wrap lines the same way as
gocui does. The tests that are added here are the same ones as in gocui for its
lineWrap function, but we'll extend them a bit in later commits in this branch.
2024-12-23 12:24:09 +01:00
Stefan Haller
2b49865d0d Fix: set state to nil when patch building view loses focus
This is also what we do in the staging controller, and it makes it so that when
you exit the patch building view and then enter it again (for another file, or
the same one) we select the first hunk again.
2024-12-23 12:24:09 +01:00