Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ neogit.setup {
disable_context_highlighting = false,
-- Disables signs for sections/items/hunks
disable_signs = false,
-- Offer to force push when branches diverge
prompt_force_push = true,
-- Changes what mode the Commit Editor starts in. `true` will leave nvim in normal mode, `false` will change nvim to
-- insert mode, and `"auto"` will change nvim to insert mode IF the commit message is empty, otherwise leaving it in
-- normal mode.
Expand Down
2 changes: 2 additions & 0 deletions doc/neogit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ to Neovim users.
disable_context_highlighting = false,
-- Disables signs for sections/items/hunks
disable_signs = false,
-- Offer to force push when branches diverge
prompt_force_push = true,
-- Changes what mode the Commit Editor starts in. `true` will leave nvim in normal mode, `false` will change nvim to
-- insert mode, and `"auto"` will change nvim to insert mode IF the commit message is empty, otherwise leaving it in
-- normal mode.
Expand Down
2 changes: 2 additions & 0 deletions lua/neogit/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ end
---@field disable_hint? boolean Remove the top hint in the Status buffer
---@field disable_context_highlighting? boolean Disable context highlights based on cursor position
---@field disable_signs? boolean Special signs to draw for sections etc. in Neogit
---@field prompt_force_push? boolean Offer to force push when branches diverge
---@field git_services? table Templartes to use when opening a pull request for a branch
---@field fetch_after_checkout? boolean Perform a fetch if the newly checked out branch has an upstream or pushRemote set
---@field telescope_sorter? function The sorter telescope will use
Expand Down Expand Up @@ -356,6 +357,7 @@ function M.get_default_values()
disable_hint = false,
disable_context_highlighting = false,
disable_signs = false,
prompt_force_push = true,
graph_style = "ascii",
commit_date_format = nil,
log_date_format = nil,
Expand Down
5 changes: 3 additions & 2 deletions lua/neogit/popups/push/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local logger = require("neogit.logger")
local notification = require("neogit.lib.notification")
local input = require("neogit.lib.input")
local util = require("neogit.lib.util")
local config = require("neogit.config")

local FuzzyFinderBuffer = require("neogit.buffers.fuzzy_finder")

Expand Down Expand Up @@ -41,8 +42,8 @@ local function push_to(args, remote, branch, opts)
local using_force = vim.tbl_contains(args, "--force") or vim.tbl_contains(args, "--force-with-lease")
local updates_rejected = string.find(table.concat(res.stdout), "Updates were rejected") ~= nil

-- Only ask the user whether to force push if not already specified
if res and res.code ~= 0 and not using_force and updates_rejected then
-- Only ask the user whether to force push if not already specified and feature enabled
if res and res.code ~= 0 and not using_force and updates_rejected and config.values.prompt_force_push then
logger.error("Attempting force push to " .. name)

local message = "Your branch has diverged from the remote branch. Do you want to force push?"
Expand Down
Loading