@@ -8,6 +8,12 @@ local notification = require("neogit.lib.notification")
8
8
local config = require (" neogit.config" )
9
9
local a = require (" plenary.async" )
10
10
11
+ --- @param popup PopupData
12
+ --- @return boolean
13
+ local function allow_empty (popup )
14
+ return vim .tbl_contains (popup :get_arguments (), " --allow-empty" )
15
+ end
16
+
11
17
local function confirm_modifications ()
12
18
if
13
19
git .branch .upstream ()
@@ -37,7 +43,7 @@ local function do_commit(popup, cmd)
37
43
end
38
44
39
45
local function commit_special (popup , method , opts )
40
- if not git .status .anything_staged () then
46
+ if not git .status .anything_staged () and not allow_empty ( popup ) then
41
47
if git .status .anything_unstaged () then
42
48
if input .get_permission (" Nothing is staged. Commit all uncommitted changed?" ) then
43
49
opts .all = true
@@ -97,7 +103,7 @@ local function commit_special(popup, method, opts)
97
103
end
98
104
99
105
function M .commit (popup )
100
- if not git .status .anything_staged () then
106
+ if not git .status .anything_staged () and not allow_empty ( popup ) then
101
107
notification .warn (" No changes to commit." )
102
108
return
103
109
end
@@ -106,7 +112,7 @@ function M.commit(popup)
106
112
end
107
113
108
114
function M .extend (popup )
109
- if not git .status .anything_staged () then
115
+ if not git .status .anything_staged () and not allow_empty ( popup ) then
110
116
if git .status .anything_unstaged () then
111
117
if input .get_permission (" Nothing is staged. Commit all uncommitted changes?" ) then
112
118
git .status .stage_modified ()
@@ -175,7 +181,7 @@ function M.absorb(popup)
175
181
return
176
182
end
177
183
178
- if not git .status .anything_staged () then
184
+ if not git .status .anything_staged () and not allow_empty ( popup ) then
179
185
if git .status .anything_unstaged () then
180
186
if input .get_permission (" Nothing is staged. Absorb all unstaged changes?" ) then
181
187
git .status .stage_modified ()
0 commit comments