summaryrefslogtreecommitdiffstats
path: root/pkg/commands
AgeCommit message (Collapse)Author
2024-05-19Remove redundant variable dedeclarationsJesse Duffield
In go 1.22, loop variables are redeclared with each iteration of the loop, rather than simple updated on each iteration. This means that we no longer need to manually redeclare variables when they're closed over by a function.
2024-05-18Fix stashing partialy staged files for git version >= 2.35.0dsolerhww
Use `git stash push --staged` git feature available on git version > 2.35.0.
2024-05-15Use ScanLinesAndTruncateWhenLongerThanBuffer instead of bufio.ScanLinesStefan Haller
2024-05-15Put subject last in git log's prettyFormatStefan Haller
We are going to truncate overly long lines returned from git log, and the most likely field that is going to make the line too long is the subject; so we must put it last, otherwise we'd end up with not enough fields to split when it's too long. It might not be obvious from the diff what's happening to the mock command output in the test: it didn't have the divergence field (">") at all, which was kind of a bug. It didn't matter for these tests though, because we are not testing the divergence here, and our production code happens to be resilient against it missing. But now we must add the ">" field before the subject.
2024-05-15Handle scanner error in RunAndProcessLinesStefan Haller
Scanners can return errors (e.g. ErrTooLong), and if we don't handle it, the cmd.Wait() call below will block forever because nobody drains the command's output. This happens for CommitLoader.GetCommits when there's a commit whose subject line is longer than approx. 65500 characters; in that case, lazygit would lock up completely. With this fix it remains usable, but the commit list is truncated before the bad commit, which is not good enough. We'll improve that in the remaining commits of this branch.
2024-04-28chore: fix some comments and typosknowmost
Signed-off-by: knowmost <knowmost@outlook.com>
2024-04-25Support external diff command in diffing modeStefan Haller
2024-04-25Use git.paging.colorArg in diffing mode diffStefan Haller
2024-04-25Cleanup: use separate Arg calls for unrelated argumentsStefan Haller
2024-04-24chore: use errors.New to replace fmt.Errorf with no parameters.ChengenH
2024-04-22Drop update-ref commands at the top of the rebase-todo fileStefan Haller
The rebase.updateRefs feature of git is very useful to rebase a stack of branches and keep everything nicely stacked; however, it is usually in the way when you make a copy of a branch and want to rebase it "away" from the original branch in some way or other. For example, the original branch might sit on main, and you want to rebase the copy onto devel to see if things still compile there. Or you want to do some heavy history rewriting experiments on the copy, but keep the original branch in case the experiments fail. Or you want to split a branch in two because it contains two unrelated sets of changes; so you make a copy, and drop half of the commits from the copy, then check out the original branch and drop the other half of the commits from it. In all these cases, git's updateRefs feature insists on moving the original branch along with the copy in the first rebase that you make on the copy. I think this is a bug in git, it should create update-ref todos only for branches that point into the middle of your branch (because only then do they form a stack), not when they point at the head (because then it's a copy). I had a long discussion about this on the git mailing list [1], but people either don't agree or don't care enough. So we fix this on our side: whenever we start a rebase for whatever reason, be it interactive, non-interactive, or behind-the-scenes, we drop any update-ref todos that are at the very top of the todo list, which fixes all the above-mentioned scenarios nicely. I will admit that there's one scenario where git's behavior is the desired one, and the fix in this PR makes it worse: when you create a new branch off of an existing one, with the intention of creating a stack of branches, but before you make the first commit on the new branch you realize some problem with the first branch (e.g. a commit that needs to be reworded or dropped). It this case you do want both branches to be affected by the change. In my experience this scenario is much rarer than the other ones that I described above, and it's also much easier to recover from: just check out the other branch again and hard-reset it to the rebased one. [1] https://public-inbox.org/git/354f9fed-567f-42c8-9da9-148a5e223022@haller-berlin.de/
2024-04-22Switch git-todo-parser from fsmiamoto original repo to stefanhaller's forkStefan Haller
Sometimes it takes a while to get PRs accepted upstream, and this blocks our progress. Since I'm pretty much the only one making changes there anyway, it makes sense to point to my fork directly.
2024-04-12rename sha to hash 10, last remaining sha (hopefully)pikomonde
2024-04-12rename sha to hash 9, case: Shapikomonde
2024-04-12rename sha to hash 8, update some log and commentpikomonde
2024-04-12rename sha to hash 6, update short hashpikomonde
2024-04-12rename sha to hash 5pikomonde
2024-04-12rename sha to hash 3pikomonde
2024-04-12rename sha to hash 2pikomonde
2024-04-12rename sha to hashpikomonde
2024-04-12renaming variable to CommitHashpikomonde
2024-04-12standardize 'Commit Sha' to 'Commit Hash'pikomonde
2024-04-09TERM: remove TERM variable hard-coded value setEmanuele "Lele" Calo
2024-03-28Fix rewording signed commits when the log.showsignature git config is trueStefan Haller
For people who have the log.showsignature git config set to true, trying to reword a signed commit would put the signature verification into the subject field and the commit subject into the description field of the commit message panel. Amending commits, adding co-authors to a commit, and copying a commit message to the clipboard would all be broken in a similar way.
2024-03-28Fix the "Add to .git/info/exclude" command in submodules or worktreesStefan Haller
2024-03-26Fix deleting update-ref todosStefan Haller
It is a bad idea to read a git-rebase-todo file, remove some update-ref todos, and write it back out behind git's back. This will cause git to actually remove the branches referenced by those update-ref todos when the rebase is continued. The reason is that git remembers the refs affected by update-ref todos at the beginning of the rebase, and remembers information about them in the file .git/rebase-merge/update-refs. Then, whenever the user performs a "git rebase --edit-todo" command, it updates that file based on whether update-ref todos were added or removed by that edit. If we rewrite the git-rebase-todo file behind git's back, this updating doesn't happen. Fix this by not updating the git-rebase-todo file directly in this case, but performing a "git rebase --edit-todo" command where we set ourselves as the editor and change the file in there. This makes git update the bookkeeping information properly. Ideally we would use this method for all cases where we change the git-rebase-todo file (e.g. moving todos up/down, or changing the type of a todo); this would be cleaner because we wouldn't mess with git's private implementation details. I tried this, but unfortunately it isn't fast enough. Right now, moving a todo up or down takes between 1 and 2ms on my machine; changing it to do a "git rebase --edit-todo" slows it down to over 100ms, which is unacceptable.
2024-03-26Cleanup: update outdated commentStefan Haller
We used to pass the todo string, but this has changed to instructions a while ago.
2024-03-22Make it easy to create "amend!" commitsStefan Haller
To support this, we turn the confirmation prompt of the "Create fixup commit" command into a menu; creating a fixup commit is the first entry, so that "shift-F, enter" behaves the same as before. But there are additional entries for creating "amend!" commits, either with or without file changes. These make it easy to reword commit messages of existing commits.
2024-03-22Support editing multiple files at once using range selectionStefan Haller
We pass all of them to a single editor command, hoping that the editor will be able to handle multiple files (VS Code and vim do). We ignore directories that happen to be in the selection range; this makes it easier to edit multiple files in different folders in tree view. We show an error if only directories are selected, though.
2024-03-17When checking out a remote branch by name, ask the user howStefan Haller
The choices are to create a new local branch that tracks the remote, or a detached head.
2024-03-16Allow deleting update-ref todosStefan Haller
2024-03-16Allow moving update-ref todos up/downStefan Haller
2024-03-16Store full ref in Name field of update-ref commitsStefan Haller
Strip the prefix at presentation time instead. This makes it easier to find update-ref todos in order to move them up/down, or delete them.
2024-03-11Extract functions AddCoAuthorToMessage and AddCoAuthorToDescriptionStefan Haller
In this commit we only need the former; the latter will be reused later in this branch.
2024-03-09Replace DOS linefeeds with Unix line feeds when loading a commit messageStefan Haller
I have seen some commit messages that contain CRLF instead of just LF; I'm not sure if these were created by a broken git client, but they exist, so we need to deal with them. Editing them when rewording a commit sort of works, but is a little strange; the \r characters are invisble, so you need an extra arrow key press to skip over them. In the next commit we are going to add more logic related to line breaks, and it is getting confused by the \r, so it is becoming more important to fix this. The easiest fix is to normalize the line endings right after loading.
2024-03-07Show all submodules recursivelyStefan Haller
2024-03-07Pass entire submodule to UpdateUrl instead of name and path separatelyStefan Haller
This will make the next commit slightly simpler.
2024-03-07Fix deleting submodule where name and path are differentStefan Haller
2024-03-02Remove support for old-style non-interactive rebasesStefan Haller
When doing a non-interactive rebase using a version of git earlier than 2.26, or by explicitly calling `git -c rebase.backend=apply rebase`, lazygit can display the pending todos by parsing the numbered patch files in `.git/rebase-apply/`. Unfortunately, support for this has been broken for more than three years because of the change in 682db77401e (the string literal "normal" should have been changed to REBASE_MODE_NORMAL instead of REBASE_MODE_MERGING). It's not an important bug since you can only get into this situation by doing a rebase outside of lazygit, and then only with a pretty old git version or by using very uncommon git options. So instead of fixing the bug, just remove the code.
2024-03-02Break git.merging.args config into separate arguments on whitespaceStefan Haller
This makes it possible again to pass multiple arguments, for example "--ff-only --autostash". This won't work correctly if you want to use an argument that contains a space, but it's very unlikely that people will want to do that, so I think this is good enough.
2024-03-02Add a test that demonstrates a bug with multiple args in git.merging.args configStefan Haller
We are currently passing the whole string as a single argument, which doesn't work of course.
2024-02-21Add author filtering to commit viewTristan Déplantes
This commit introduces a new feature to the commit view, allowing users to filter commits based on the author's name or email address. Similar to the existing path filtering functionality, accessible through <c-s>, this feature allows users to filter the commit history by the currently selected commit's author if the commit view is focused, or by typing in the author's name or email address. This feature adds an entry to the filtering menu, to provide users with a familiar and intuitive experience
2024-02-18Set diff.noprefix=false for all other diff commands tooStefan Haller
This fixes problems with being able to stage things in a custom patch correctly.
2024-02-18Fix problems with patches if `git diff` was customized with config.Matthias Richerzhagen
2024-02-16Deprecate git.log.showGraph and git.log.order configAlex March
Added identical properties to AppState that should eventually have their defaults set.
2024-02-13Support range select removing files from a commitAaron Hoffman
2024-01-28Support selecting file range in patch builderAaron Hoffman
test: add move_range_to_index test: add toggle_range
2024-01-28Show mode-specific keybinding suggestionsJesse Duffield
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-26Use inline status for fetching remotesStefan Haller
2024-01-25Support range select for staging/discarding filesJesse Duffield
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.