Skip to content

Commit a6fc7be

Browse files
committed
option to turn off hard reset backups
1 parent 2dec226 commit a6fc7be

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lua/neogit/config.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ end
332332
---@field disable_signs? boolean Special signs to draw for sections etc. in Neogit
333333
---@field simple_headers? boolean Use text headers instead of windows
334334
---@field force_if_includes? boolean Add --force-if-includes if --force-with-lease is set
335+
---@field hard_reset_backup? boolean Do a backup commit before a hard reset
335336
---@field log_view_esc_close? boolean if this is set to false ESC doesn't close log view
336337
---@field prompt_force_push? boolean Offer to force push when branches diverge
337338
---@field git_services? table Templartes to use when opening a pull request for a branch
@@ -383,6 +384,7 @@ function M.get_default_values()
383384
disable_signs = false,
384385
simple_headers = false,
385386
force_if_includes = true,
387+
hard_reset_backup = true,
386388
log_view_esc_close = true,
387389
prompt_force_push = true,
388390
graph_style = "ascii",
@@ -1143,6 +1145,7 @@ function M.validate_config()
11431145
validate_type(config.disable_signs, "disable_signs", "boolean")
11441146
validate_type(config.simple_headers, "simple_headers", "boolean")
11451147
validate_type(config.force_if_includes, "force_if_includes", "boolean")
1148+
validate_type(config.hard_reset_backup, "hard_reset_backup", "boolean")
11461149
validate_type(config.log_view_esc_close, "log_view_esc_close", "boolean")
11471150
validate_type(config.telescope_sorter, "telescope_sorter", "function")
11481151
validate_type(config.use_per_project_settings, "use_per_project_settings", "boolean")

lua/neogit/lib/git/reset.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local git = require("neogit.lib.git")
2+
local config = require("neogit.config")
23

34
---@class NeogitGitReset
45
local M = {}
@@ -20,7 +21,9 @@ end
2021
---@param target string
2122
---@return boolean
2223
function M.hard(target)
23-
git.index.create_backup()
24+
if config.values.hard_reset_backup then
25+
git.index.create_backup()
26+
end
2427

2528
local result = git.cli.reset.hard.args(target).call()
2629
return result.code == 0

0 commit comments

Comments
 (0)