1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-19 17:02:18 +03:00

1249 Commits

Author SHA1 Message Date
Stefan Haller
712923e366 Press enter in main view of files/commitFiles to enter staging/patch-building
This was already possible, but only when a file was selected, and it woudln't
always land on the right line when a pager was used. Now it's also possible to
do this for directories, and it jumps to the right line.

At the moment this is a hack that relies on delta's hyperlinks, so it only works
on lines that have hyperlinks (added and context).

The implementation is very hacky for other reasons too (e.g. the addition of the
weirdly named ClickedViewRealLineIdx to OnFocusOpts).
2025-04-16 16:30:41 +02:00
Stefan Haller
2bfad5a3ef Remove utils.Clamp, use lo.Clamp instead 2025-04-16 16:30:41 +02:00
Stefan Haller
b0ab6529c1 Escape special characters when git-ignoring files 2025-04-13 18:25:24 +10:00
Ruud Kamphuis
12820481e6 Add runCommand function to Go template syntax
This makes it possible to use date and time in initial values like this:

```yaml
initialValue: 'ruudk/{{ runCommand "date +\"%Y/%-m\"" }}/'
```

I want to use this to configure my BranchPrefix like this:

```yaml
git:
  branchPrefix: 'ruudk/{{ runCommand "date +\"%Y/%-m\"" }}/'
```
2025-04-09 10:44:36 +02:00
Stefan Haller
82e1caa166 Remove conditional code related to git earlier than 2.22 2025-04-09 10:40:52 +02:00
Stefan Haller
765168b9d7 Remove canUsePushTrack parameter of obtainBranches function
It was only needed for git versions older than 2.22.
2025-04-09 10:40:52 +02:00
Stefan Haller
ebb576feac Provide conflict resolution dialogs for non-textual conflicts 2025-04-09 10:27:57 +02:00
Stefan Haller
2e1be45957 Better main view display for conflicing files
For the less common conflict types DD, AU, UA, DU, and UD, we would previously
only show "* Unmerged path" in the main view, which isn't helpful. Also, for
some of these we would split the main view and show this text both in the
unstaged changes and staged changes views, which is a bit embarrassing.

Improve this by offering more explanation about what's going on, and what the
most likely way to resolve the situation is for each case.
2025-04-09 10:27:57 +02:00
Stefan Haller
dc48cf963a Add config os.shellFunctionsFile 2025-04-07 14:35:40 +02:00
Stefan Haller
4e5e21f946 Revert commits related to using an interactive shell for running shell commands
This reverts commits f28b6f439d, dbd407c01d, 5fac40c129, and 5a3049485c.
2025-04-07 14:35:40 +02:00
Chris McDonnell
c06d4e7b18 fix: Make tag operation use GPG helper to run signing in sub-process 2025-03-24 08:41:58 +01:00
Chris McDonnell
f779a5878d refactor: Express WithGpgHelper with a config key parameter 2025-03-24 08:41:58 +01:00
Chris McDonnell
6fb3b7430c refactor: Make commit.gpgSign match official capitalization
The actual usage is case insensitive, so this doesn't actually matter.
But if fills my heart with joy.

The test is case sensitive, but the actual response to `git config
commit.gpgSign` is equivalent to `git config commit.gppsign`
2025-03-24 08:41:58 +01:00
Chris McDonnell
52da806c57 refactor: Rename UsingGpg to make room for Gpg Tag logic 2025-03-24 08:41:58 +01:00
Korbinian Schweiger
b102646b20 Commit without pre-commit hooks is independent on prefix
Add verify flag

Add and update integration tests

Rename verify to forceSkipHooks

Adapt CommitSkipHooks integration test to actually use a hook

Remove forceSkipHooks param from OnConfirm et al

Simplify tests
2025-03-22 11:04:28 +01:00
Cesar Andres
5de735f1ac feat(submodules): add method to bulk init and update submodules 2025-03-22 09:54:32 +01:00
Stefan Haller
2dfc3491bd Rename Name to Path in File and CommitFile
Name was very confusing and misleading.
2025-03-20 12:31:34 +01:00
Stefan Haller
f7295a97c0 Add a "Content of selected file" entry to the copy menu for commit files
This is useful for copying the entire content of the selected file as it was at
the selected commit.

We only add it to the commit files panel; it is not needed in the files panel,
because there you can simply press "e" to edit the file.
2025-03-20 11:52:53 +01:00
Stefan Haller
3e15be576e Drop the git config cache when getting focus
This allows changing git config values while lazygit is running (e.g. in a
different terminal tab, or even in lazygit's ":" shell prompt), and have them
take effect immediately, while still getting some benefit from caching them
while lazygit is in the foreground.
2025-03-20 11:50:28 +01:00
Stefan Haller
cf27399571 Revert "Skip post-checkout hook when discarding changes"
This reverts commit 964278255b8a0a460b74e459938057002d12390e.
2025-03-20 11:41:15 +01:00
Partho Kunda
7a1b63182d Commit only tracked files in tracked only filter view 2025-03-17 19:51:27 +01:00
Chris McDonnell
c1ca1c8f99 URL encode gitlab brackets to make consistent with branch names
Some operating systems 'open' implementations do not like
when some special characters are unencoded, so they will
double-enconde the branch name, which we already encode.

This particularly matters since branch names with / are common
2025-03-12 09:04:04 +11:00
Kevin Radloff
be7583dd40 Update to go 1.24 2025-03-08 14:53:54 -05:00
Stefan Haller
f28b6f439d Support fish when running shell command
This should allow using custom shell functions in lazygit's : prompt.
2025-03-06 08:11:32 +01:00
Stefan Haller
a4d6d020c4 Remove unused functions
For some reason the //nolint:golint,unused comment no longer seems to work after
I updated gopls (I think).

But I also don't understand why we mark unused stuff with linter comments
instead of just getting rid of it.
2025-03-03 21:23:29 +01:00
Stefan Haller
964278255b Skip post-checkout hook when discarding changes
Some people have post-checkout hooks that take a lot of time, which makes
discarding changes slow. You can argue that a post-checkout hook should only run
when you switch branches, so it doesnt't have to run when checking out single
files or directories. You can also argue that lazygit might have implemented
discarding changes by taking the current patch and applying it in reverse, which
wouldn't have run a post-checkout hook either.

So disable them for all cases where we use git checkout with a path; this
includes checking out a file from the commit files view.
2025-02-25 11:39:27 +01:00
Matteo Golinelli
d92c6d116b Replace --include-untracked with -u in stash show command for compatibility and update failing tests 2025-02-22 08:17:38 +11:00
Matteo Golinelli
343a3e466a Add --include-untracked flag to stash show command 2025-02-22 08:17:38 +11: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
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
Erich Fussi
2a87c048b9 Add '--' to 'git rev-list' to disambiguate branch name from path 2025-01-19 14:33:42 +01:00
Stefan Haller
dbd407c01d Use interactive shell for running shell commands only if shell is bash or zsh
We use an interactive shell so that users can use their custom shell aliases in
lazygit's shell prompt, which is convenient; however, this only really works for
shells like bash or zsh. We know it doesn't work for fish or nushell (because
these use different names for the $? variable); so use an interactive shell only
if the user's shell is either bash or zsh.
2025-01-09 09:29:31 +01: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
Nathan Baulch
508cdb40a8 Fix typos 2025-01-03 10:50:36 +11:00
RiceChuan
c834e132c7 chore: use errors.New to replace fmt.Errorf with no parameters
Signed-off-by: RiceChuan <lc582041246@gmail.com>
2025-01-02 17:27:54 +11:00
John Mutuma
d7d5733a71 Revert unwanted change 2025-01-02 16:52:24 +11:00
John Mutuma
5240b2862f Add worktree option to fast forwarding operation 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
Wayne Bowie
aad3dc42a7 Allow on prem Azure DevOps Server pull request 2025-01-02 15:10:02 +11:00
Stefan Haller
5fac40c129 Fix hang when returning from shell command
In 5a3049485c we changed the execution of shell commands to use an interactive
shell (-i), because this allows users to use aliases or shell functions, which
is a nice convenience.

Since then, however, many users have reported problems with lazygit not coming
back to the foreground after executing a shell command. Some users report that
appending "; exit" to the end of the command line solves this. I don't really
understand what the cause of this problem was, or why appending "; exit" solves
it, but if it helps, let's do it.
2024-12-28 14:53:57 +01:00
Stefan Haller
a9ef69b9c7 Fix moving a commit across a branch boundary in a stack
See the previous commit for a detailed explanation.
2024-12-23 12:18:48 +01:00
Stefan Haller
078445db63 Allow deleting a merge commit
For non-merge commits we change "pick" to "drop" when we delete them. We do this
so that we can use the same code for dropping a commit no matter whether we are
in an interactive rebase or not. (If we aren't, we could just as well delete the
pick line from the todo list instead of setting it to "drop", but if we are, it
is better to keep the line around so that the user can change it back to "pick"
if they change their mind.)

However, merge commits can't be changed to "drop", so we have to delete them
from the todo file. We add a new daemon instruction that does this.

We still don't allow deleting a merge commit from within an interactive rebase.
The reason is that we don't show the "label" and "reset" todos in lazygit, so
deleting a merge commit would leave the commits from the branch that is being
merged in the list as "pick" commits, with no indication that they are going to
be dropped because they are on a different branch, and the merge commit that
would have brought them in is gone. This could be very confusing.
2024-12-23 12:12:45 +01:00
Stefan Haller
64eb3d560b Simplify finding rebase todos
One of the comments we are deleting here said:

  // Comparing just the hash is not enough; we need to compare both the
  // action and the hash, as the hash could appear multiple times (e.g. in a
  // pick and later in a merge).

I don't remember what I was thinking when I wrote this code, but it's nonsense
of course. Maybe I was thinking that the hash that appears in a "merge" todo
would be the hash of the commit that is being merged in (which would then
actually appear in an earlier pick), but it isn't, it's the hash of the merge
commit itself (so that the rebase can reuse its commit message). Which means
that hashes are unique, no need to compare the action.
2024-12-23 12:12:45 +01:00
johannaschwarz
f455f99705 Add user config gui.showNumstatInFilesView
When enabled, it adds "+n -m" after each file in the Files panel to show how
many lines were added and deleted, as with `git diff --numstat` on the command
line.
2024-12-08 12:09:47 +01:00
Stefan Haller
7fb9e8fa9a Respect the diff context size when showing a range diff
This applies to both the "sticky" range diff when diffing mode is on, and the
more temporary one when selecting a range of commits.
2024-12-01 13:01:16 +01:00
Stefan Haller
5cca4c7063 Cleanup: move adding --ignore-all-space arg to DiffCmdObj
It is needed by both call sites of this function. This has the added benefit
that the argument doesn't unnecessarily show up in the status view when diffing
mode is on.
2024-12-01 13:01:15 +01:00
Stefan Haller
17bb3970c1 Filter out merge commits when generating todo changes in InteractiveRebase
We will need this because under some conditions we are going to use this
function to edit a range of commits, and we can't set merge commits to "edit".
This corresponds to the code in startInteractiveRebaseWithEdit which has similar
logic.

It is a bit unfortunate that we will have these two different ways of setting
todos to edit: startInteractiveRebaseWithEdit does it after stopping in the
rebase, in the Then function of its refresh, but InteractiveRebase does it in
the daemon with a ChangeTodoActionsInstruction. It still makes sense though,
given how InteractiveRebase works.

This not only affects "edit", but also "drop", "fixup", and "squash".
Previously, when trying to use these for a range selection that includes a merge
commit, they would fail with the cryptic error message "Some todos not found in
git-rebase-todo"; now they simply exclude the merge commit. I'm not sure if one
is better or worse than the other, and we should probably simply disable the
commands when a merge commit is selected, but that's out of scope in this PR.
2024-12-01 11:05:45 +01:00
Stefan Haller
c1b4201726 Allow deleting a range selection of branches
We allow deleting remote branches (or local and remote branches) only if *all*
selected branches have one.

We show the a warning about force-deleting as soon as at least one of the
selected branches is not fully merged.

The added test only tests a few of the most interesting cases; I didn't try to
cover the whole space of possible combinations, that would have been too much.
2024-12-01 10:59:54 +01:00
LU Jialin
de8dc935a3 use unsigned integer in test and fix CI/linter complaint 2024-11-19 08:21:19 +11:00