1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
Commit Graph

5100 Commits

Author SHA1 Message Date
Aaron Hoffman
15d5261933 Support range select removing files from a commit 2024-02-13 09:10:15 -06:00
Stefan Haller
beb730a9e6
Change default of git.log.showGraph to 'always' (#3314)
Change default of git.log.showGraph to 'always'; most people seem to
prefer it to be on.

Fixes #3312.
2024-02-13 14:41:01 +01:00
Stefan Haller
b1d05b6371 Change default of git.log.showGraph to 'always'
Most people seem to prefer it to be on.
2024-02-13 14:34:40 +01:00
Stefan Haller
0c5212ae0b
Disallow cherry-picking merge commits (#3316)
Cherry-picking merge commits is currently not supported because of the
way copy/pasting is currently implemented. Disable the command with a
proper error message if the user tries to copy a merge commit, instead
of running into the confusing error message that git would otherwise
give, see #1374.

While we're at it, disable it also when trying to copy an "update-ref"
todo, which doesn't make sense.
2024-02-12 12:03:23 +01:00
Stefan Haller
bc6616d511 Disallow cherry-picking merge commits 2024-02-10 11:27:28 +01:00
Stefan Haller
2c82b3f8dd Disallow cherry-picking update-ref todos 2024-02-10 11:27:28 +01:00
Stefan Haller
dc40fb5267 Cleanup: remove unused method 2024-02-10 11:05:09 +01:00
Stefan Haller
49df908dd3
Fix cherrypick demo (#3287)
Cherrypick selections are now cleared after pasting (#3240), so the demo
needs a tiny change to reflect that.

- **PR Description**
The cherry pick demo is failing after the changes in #3240. This is just
a small update to that demo to reflect the new (and more convenient)
behavior from #3240.

- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [ ] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] Docs (specifically `docs/Config.md`) have been updated if
necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
2024-01-30 17:10:10 +01:00
Aaron Hoffman
fdc54b7455 Fix cherrypick demo
Cherrypick selections are now cleared after pasting (#3240), so the demo
needs a tiny change to reflect that.
2024-01-30 09:27:44 -06:00
Stefan Haller
607034a61e
Clear cherry-picked commits after pasting (#3240)
It can be tedious after each cherry-pick opearation to clear the
selection by pressing escape in order for lazygit to stop displaying
info about copied commits. Also, it seems to be a rare case to
cherry-pick commits to more than one destination.

The simplest solution to address this issue is to clear the selection
upon paste, including merge conflict scenario.
Previously discussed in #3198.
2024-01-30 08:59:38 +01:00
molejnik88
ee173ff7c9 Clear cherry-picked commits after pasting
It can be tedious after each cherry-pick opearation to clear the
selection by pressing escape in order for lazygit to stop displaying
info about copied commits. Also, it seems to be a rare case to
cherry-pick commits to more than one destination.

The simplest solution to address this issue is to clear the selection
upon paste.

The only exception is a merge conflict. Initially, I wanted to clear
selected commits in this scenario too. During a discussion we found out
that it may be convenient to have the copied commits still around.
Aborting the rebase and pasting the commits in the middle of a branch
can be a valid use case.
2024-01-30 09:21:12 +11:00
Jesse Duffield
761c77f5a2
Use slimmer scrollbars (#3283)
(hopefully) fixes https://github.com/jesseduffield/lazygit/issues/1924

The previous scrollbars were too chunky and encroached too much on a
view's content.

The new ones are slim and right-aligned so they encroach into dead space
between views which is much better.

Before:

![image](https://github.com/jesseduffield/lazygit/assets/8456633/fe125804-0cb8-4f9b-be4c-5710fd73ac14)


After:

![image](https://github.com/jesseduffield/lazygit/assets/8456633/8ae18f96-e2fd-46ff-be9a-09e745da1177)

Admittedly, the original scrollbars look more like typical scrollbars
and do a better job at telling you where the start and end of the
scrollbar is. We experimented with having special characters for
scrollbar bounds in the slim version but it all looked pretty ugly, and
there's just not many ascii characters to choose from.

Based on gocui PR: https://github.com/jesseduffield/gocui/pull/45

The important changes are in 
vendor/github.com/jesseduffield/gocui/gui.go
vendor/github.com/jesseduffield/gocui/scrollbar.go

The other changes are just modules being updated.

- **PR Description**

- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [x] Docs (specifically `docs/Config.md`) have been updated if
necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
2024-01-30 08:49:36 +11:00
Jesse Duffield
f9e8428061 Use slimmer scrollbars
The previous scrollbars were too chunky and encroached too much on a view's content.

The new ones are slim and right-aligned so they encroach into dead space between views
which is much better
2024-01-30 08:44:03 +11:00
Stefan Haller
9d840088ac
Add command to squash all fixups in the current branch (#3274)
Add command to squash all fixups in the current branch.

To do that, change the "Apply fixup commits" command to show a menu with
the two choices "in current branch" and "above the selected commit"; we
make "in current branch" the default, as it's the more useful one most
of the time, even though it is a breaking change for those who are used
to "shift-S enter" meaning "squash above selected".

Fixes #3263.
2024-01-29 10:05:40 +01:00
Stefan Haller
b133318b40 Add command to squash all fixups in the current branch
To do that, change the "Apply fixup commits" command to show a menu with the two
choices "in current branch" and "above the selected commit"; we make "in current
branch" the default, as it's the more useful one most of the time, even though
it is a breaking change for those who are used to "shift-S enter" meaning
"squash above selected".
2024-01-29 09:37:47 +01:00
Stefan Haller
24e79a057c
Fix refreshing custom patch view when adding first file to custom patch (#3266)
Fixes #3258.
2024-01-28 10:01:49 +01:00
Stefan Haller
c66667c8c1 Fix main view refresh after adding the first file to a custom patch
This broke with 240948b.
2024-01-28 09:49:56 +01:00
Stefan Haller
e8e7ddea45 Fix typo 2024-01-28 09:49:56 +01:00
Jesse Duffield
6322944a5e
Support selecting file range in patch builder (#3259)
- **PR Description**
Adds support for selecting a range of files and adding them to a custom
patch. Closes #3251
The behavior for node selection is the same as used in #3248 because I
copied the approach. Please let me know if there's a mismatch or if
something else is preferred.

I also copied `normalisedSelectedNodes` and
`isDescendentOfSelectedNodes` verbatim, just adapted their signature
types.

It seems like we could share those two functions between
`[]*filetree.CommitFileNode` and `[]*filetree.FileNode` by making those
functions like `func normalisedSelectedCommitNodes[T any](selectedNodes
[]*filetree.Node[T]) []*filetree.Node[T]`. That would require calling
them with a `lo.Map(...)` which returns `node.GetRaw()`, and I feel
weird about giving a different type back to the calling function.

I added a couple of test cases, and all of the existing patch tests pass
for me, but please do let me know if there are any other test cases I
should add.

- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [ ] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] Docs (specifically `docs/Config.md`) have been updated if
necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
2024-01-28 12:13:42 +11:00
Aaron Hoffman
510f9a1ae1 Support selecting file range in patch builder
test: add move_range_to_index

test: add toggle_range
2024-01-28 12:00:47 +11:00
Jesse Duffield
9b2a5f636a
Warn users when attempting to cherry pick with old key (#3271)
I wrote this feature and even I sometimes use the wrong key so I want to
make this very clear to users so that there's no confusion.

We can get rid of this once users have had time to adjust


![image](https://github.com/jesseduffield/lazygit/assets/8456633/8a453eaf-381d-468e-8280-58516eead43a)


- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [x] Docs (specifically `docs/Config.md`) have been updated if
necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
2024-01-28 12:00:03 +11:00
Jesse Duffield
e1aa68a7bd Warn users when attempting to cherry pick with old key
I wrote this feature and even I sometimes use the wrong key so I want
to make this very clear to users so that there's no confusion
2024-01-28 11:48:21 +11:00
Jesse Duffield
cf5d4d4f8e
Show better keybinding suggestions (#3203)
- **PR Description**

This PR's goal is to improve discoverability of keybindings in lazygit.
I've have a couple people in real life mention to me that it wasn't
obvious what key to press for viewing rebase options, for example.


This PR:
* shows more keybindings in the options view
* shows certain keybindings prominently in certain modes e.g. 'view
rebase options: m' when mid-rebase.

Before:

![image](https://github.com/jesseduffield/lazygit/assets/8456633/483477ef-93e1-4fd1-af86-3ffa84167f62)


After:

![image](https://github.com/jesseduffield/lazygit/assets/8456633/4c93dd19-f072-45ec-afa6-810727211f66)




- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [x] Docs (specifically `docs/Config.md`) have been updated if
necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
2024-01-28 09:27:01 +11:00
Jesse Duffield
bd7fabef1f Reduce the chance of race condition with list cursor
Before this commit, we had pkg/integration/tests/submodule/add.go
failing with a panic. I'm pretty sure the issue is this: we're now
calling quite a few GetDisabledReason calls on each layout() call,
and if a background thread happens to update a model slice while
we're doing this, we can end up with a selection index that's now
out of bounds because it hasn't been clamped to match the new list
length.

Specifically, here we had the selected index being -1 (the list starts
empty and somehow the value is -1 in this case) and then the list
gets a new submodule so the length is now 1, but the list cursor
doesn't know about this so remains on the old value. Then we confirm
the length is greater than zero and try to get the selected submodule
and get an out of bounds error.

This commit fixes the issue by clamping the selected index whenever
we get the length of the list so that it stays in-sync. This is not
a perfect solution because the length can change at any time, but
it seems to reliably fix the test, and using mutexes didn't seem to
make a difference.

Note that we're swapping the order of IFileTree and IListCursor in
the file tree view model to ensure that the list cursor's Len()
method is called (which performs the clamping).

Also, comment from the PR:
This 'trait' pattern we're using is convenient but can lead to awkward
situations. In this case we have both the list view model and the
(embedded) list cursor with a Len() method. The list cursor Len()
method just calls the list view model Len() method. But I wanted
to make it that the list view model now calls ClampSelection() on the
list cursor whenever it obtains the length. This will cause an
infinite loop because ClampSelection() internally calls Len()
(which calls the list view model's Len() method which in turn
calls ClampSelection() again, etc).

The only reason we were passing the list view model into the list
cursor was to supply the length method, so now we're just doing
that directly, and letting the list view model delegate the Len()
call to the list cursor, which now itself calls ClampSelection.
2024-01-28 09:20:52 +11:00
Jesse Duffield
1a38d515d7 Display more keybindings on-screen 2024-01-28 08:33:13 +11:00
Jesse Duffield
0f9d9e13d1 Show mode-specific keybinding suggestions
As part of making lazygit more discoverable, there are certain keys which you almost certainly
need to press when you're in a given mode e.g. 'v' to paste commits when cherry-picking. This
commit prominently shows these keybinding suggestions alongside the others in the option view.

I'm using the same colours for these keybindings as is associated with the mode elsewhere e.g.
yellow for rebasing and cyan for cherry-picking. The cherry-picking one is a bit weird because
we also use cyan text to show loaders and app status at the bottom left so it may be confusing,
but I haven't personally found it awkward from having tested it out myself.

Previously we would render these options whenever a new context was activated, but now that we
need to re-render options whenever a mode changes, I'm instead rendering them on each screen
re-render (i.e. in the layout function). Given how cheap it is to render this text, I think
it's fine performance-wise.
2024-01-28 08:33:13 +11:00
Jesse Duffield
c07b3fad64 Ensure file view length is never returned as -1
This was causing issues when obtaining selected items
2024-01-28 08:33:13 +11:00
Jesse Duffield
9bf3063457
Add loads of tooltips (#3269)
- **PR Description**

This is cherry-picked from
https://github.com/jesseduffield/lazygit/pull/3203. That PR both adds
tooltips and adds keybinding suggestions, and the latter part is having
some concurrency issues that I want to properly fix before merging.

- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [x] Docs (specifically `docs/Config.md`) have been updated if
necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
2024-01-28 08:20:51 +11:00
Jesse Duffield
7bddf53223 Improve keybinding descriptions
This adds a bunch of tooltips to keybindings and updates some keybinding descriptions (i.e. labels).

It's in preparation for displaying more keybindings on-screen (in the bottom right of the screen),
and so due in part to laziness it shortens some descriptions so that we don't need to manage both
a short and long description (for on-screen vs in-menu). Nonetheless I've added a ShortDescription
field for when we do want to have both a short and long description.

You'll notice that some keybindings I deemed unworthy of the options view have longer descriptions,
because I could get away with it.
2024-01-28 08:12:01 +11:00
Jesse Duffield
0aa6109d4d Render keybinding cheatsheet as markdown table
We're going to be adding tooltips to the cheatsheet to better explain what each actions
does. As such, we're switching to a table format rather than a list.

I'm also changing how the keys are represented, using a markdown approach rather than
an html approach
2024-01-28 08:12:01 +11:00
Stefan Haller
cb1b13e95e
Keep same selection range when quick-starting an interactive rebase (#3247)
This is useful if you want to move a range of commits, so you select
them, and then realize it's better to do it in an interactive rebase. Pressing 'i'
preserves the range now.
2024-01-26 11:26:00 +01:00
Stefan Haller
f9876c9742 Keep same selection range when quick-starting an interactive rebase
This is useful if you want to move a range of commits, so you select them, and
then realize it's better to do it in an interactive rebase. Pressing 'i'
preserves the range now.
2024-01-26 11:18:13 +01:00
Stefan Haller
d28a2ec059 Add tests for preserving the selection when pressing 'i'
Preserving the selection for a non-range selection already works as expected;
however, the test for a selection range shows an undesired behavior.
2024-01-26 11:18:06 +01:00
Stefan Haller
f226a277bf Rename MinMax to SortRange 2024-01-26 11:18:06 +01:00
Jesse Duffield
cce29209be
Add shortcuts for filtering files by status (#3137)
- 's' for showing only staged files
- 'u' for showing only unstaged files
- 'r' for resetting the filter

- **PR Description**

- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [x] Docs (specifically `docs/Config.md`) have been updated if
necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->

I've thought about adding `disabled` reasons for them but they kinda
don't make sense since if there are only `unstaged` files, disabling the
`Show only staged files` makes no sense because the `Show only unstaged
files` shows nothing different so we should disable that too, and then
what's the point of having a menu if everything except for `reset` is
disabled.
2024-01-26 20:57:12 +11:00
Luka Markušić
efb6524fa0 Add shortcuts for filtering files by status
- 's' for showing only staged files
- 'u' for showing only unstaged files
- 'r' for resetting the filter
2024-01-26 20:53:16 +11:00
Stefan Haller
a65f003ccc
Inline status for fetching remotes (#3238)
When fetching a remote in the remotes tab, show the status inline (i.e.
in the list row of the remote), like we do when fast-forwarding a branch
in the branches panel.
2024-01-26 08:48:05 +01:00
Stefan Haller
b485363006 Remove unused text FetchingRemoteStatus
We just removed the last use of it.
2024-01-26 08:29:04 +01:00
Stefan Haller
7fb5266027 Use inline status for fetching remotes 2024-01-26 08:29:04 +01:00
Stefan Haller
ae89dde969
Pass absolute file paths to all editor commands (#3255)
- **PR Description**

This helps work around bugs in editors that may get confused about
relative paths (like nvim-remote, see
https://github.com/neovim/neovim/issues/18519), and shouldn't have any
negative effect on others.
2024-01-26 08:26:54 +01:00
Stefan Haller
12500be554 Pass absolute file paths to all editor commands
This helps work around bugs in editors that may get confused about relative
paths (like nvim-remote, see https://github.com/neovim/neovim/issues/18519), and
shouldn't have any negative effect on others.
2024-01-25 08:56:10 +01:00
Jesse Duffield
05b97c8c8e
Support range select for staging/discarding files (#3248) 2024-01-25 18:26:24 +11:00
Jesse Duffield
0402674ee7 Fix error message for selected lines
We had the actual and expected lines swapped around erroneously
2024-01-25 11:34:59 +11:00
Jesse Duffield
269ef7f250 Support range select for staging/discarding files
As part of this, you must now press enter on a merge conflict file
to focus the merge view; you can no longer press space and if you do
it will raise an error.
2024-01-25 11:34:59 +11:00
Jesse Duffield
798225d9e1 Move file discard action into files controller
It's better just having all the keybindings in one file especially when you want to
share code
2024-01-24 20:51:00 +11:00
Stefan Haller
b7d4db2446
Use git rev-parse to obtain repository and worktree paths (#3183)
- **PR Description**
This changes GetRepoPaths() to pull information from `git rev-parse`
instead of partially reimplementing git's logic for pathfinding. This
change fixes issues with bare repos, esp. versioned homedir use cases,
by aligning lazygit's path handling to what git itself does. I believe
it also paves the way for lazygit to run from any subdirectory of a
working tree with relatively minor changes.

Addresses #1294 and #3175.

- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [x] Docs (specifically `docs/Config.md`) have been updated if
necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
2024-01-24 08:47:49 +01:00
John Whitley
3d9f1e02e5 Refactor repo_paths.go to use git rev-parse
This changes GetRepoPaths() to pull information from `git rev-parse`
instead of effectively reimplementing git's logic for pathfinding. This
change fixes issues with bare repos, esp. versioned homedir use cases,
by aligning lazygit's path handling to what git itself does.

This change also enables lazygit to run from arbitrary subdirectories of
a repository, including correct handling of symlinks, including "deep"
symlinks into a repo, worktree, a repo's submodules, etc.

Integration tests are now resilient against unintended side effects from
the host's environment variables. Of necessity, $PATH and $TERM are the
only env vars allowed through now.
2024-01-24 08:40:01 +01:00
Stefan Haller
74d937881e
Make range selections created with the mouse non-sticky (#3234)
- **PR Description**

I prefer this because I almost never use sticky range selections, but
I'm not sure everybody agrees. Also, this fixes the issue that just
clicking a line in a diff (without dragging) already creates a range
selection. It still does, technically, but it's no longer a problem
because a non-sticky one-line range selection behaves the same as a
non-range selection.

See #3233.
2024-01-24 08:26:33 +01:00
Stefan Haller
e72c759541 Make range selections created with the mouse non-sticky
I prefer this because I almost never use sticky range selections. Also, this
fixes the issue that just clicking a line in a diff (without dragging) already
creates a range selection. It still does, technically, but it's no longer a
problem because a non-sticky one-line range selection behaves the same as a
non-range selection.
2024-01-24 08:22:55 +01:00
README-bot
9cd69e46df Updated README.md 2024-01-23 22:28:37 +00:00