Skip to content

Conversation

@benjiwolff
Copy link
Contributor

@benjiwolff benjiwolff commented Nov 9, 2025

I am currently working exclusively with a large codebase. The main issue is that git status on the entire repo takes around 2 seconds which makes staging and committing super tedious and frustrating.

This implementation removes 2 git status calls before the commit message editor is shown.

The solution is not quite as pretty, so I added a configuration option.

Copy link
Member

@CKolkey CKolkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might be ways to accomplish what you are trying to do without needing to modify much. Do you mind trying my suggestions and letting me know if they work for your use case?

if not git.status.anything_staged() and not allow_empty(popup) then
notification.warn("No changes to commit.")
return
if not config.values.commit_editor.fast then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also modify the git.status.anything_staged() implementation to check git.repo.state.staged.items[1] ~= nil if "fast" is set to true. Then we don't need to skip this check, but instead just rely on the repo state data already in memory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also put not allow_empty(popup) before git.status.anything_changed(), so you could short-circuit the conditional by enabling "--allow-empty".


local function do_commit(popup, cmd)
client.wrap(cmd.arg_list(popup:get_arguments()), {
cmd.arg_list(popup:get_arguments())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried just adding an option for -m to the commit popup?
You could do popup:option("m", "message", "", "Commit message", { key_prefix = "-" }) and that also just bypasses the editor.

neogit/doc/neogit.txt

Lines 2267 to 2283 in d2a2ae4

Customizing Popups *neogit_custom_popups*
You can customize existing popups via the Neogit config.
Below is an example of adding a custom switch, but you can use any function
from the builder API.
>lua
require("neogit").setup({
builders = {
NeogitPushPopup = function(builder)
builder:switch('m', 'merge_request.create', 'Create merge request', { cli_prefix = '-o ', persisted = false })
end,
},
})
Keep in mind that builder hooks are executed at the end of the popup
builder, so any switches or options added will be placed at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants