Skip to content

Commit 683ee5d

Browse files
authored
Merge pull request #1594 from NeogitOrg/development
2 parents a38945a + 24d1375 commit 683ee5d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

lua/neogit/popups/commit/actions.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ local notification = require("neogit.lib.notification")
88
local config = require("neogit.config")
99
local a = require("plenary.async")
1010

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+
1117
local function confirm_modifications()
1218
if
1319
git.branch.upstream()
@@ -37,7 +43,7 @@ local function do_commit(popup, cmd)
3743
end
3844

3945
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
4147
if git.status.anything_unstaged() then
4248
if input.get_permission("Nothing is staged. Commit all uncommitted changed?") then
4349
opts.all = true
@@ -97,7 +103,7 @@ local function commit_special(popup, method, opts)
97103
end
98104

99105
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
101107
notification.warn("No changes to commit.")
102108
return
103109
end
@@ -106,7 +112,7 @@ function M.commit(popup)
106112
end
107113

108114
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
110116
if git.status.anything_unstaged() then
111117
if input.get_permission("Nothing is staged. Commit all uncommitted changes?") then
112118
git.status.stage_modified()
@@ -175,7 +181,7 @@ function M.absorb(popup)
175181
return
176182
end
177183

178-
if not git.status.anything_staged() then
184+
if not git.status.anything_staged() and not allow_empty(popup) then
179185
if git.status.anything_unstaged() then
180186
if input.get_permission("Nothing is staged. Absorb all unstaged changes?") then
181187
git.status.stage_modified()

lua/neogit/popups/remote/actions.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ function M.add(popup)
5454
else
5555
notification.info("Added remote " .. name)
5656
end
57+
58+
if input.get_permission("Fetch refs from " .. name .. "?") then
59+
git.fetch.fetch_interactive(name, "", { "--tags" })
60+
end
5761
end
5862
end
5963

0 commit comments

Comments
 (0)