Skip to content

Commit dbbbfe6

Browse files
committed
Notify user when checking out a local branch that tracks an upstream
branch fails.
1 parent 1df653c commit dbbbfe6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lua/neogit/lib/git/branch.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ end
9090

9191
---@param name string
9292
---@param args? string[]
93+
---@return ProcessResult
9394
function M.track(name, args)
94-
git.cli.checkout.track(name).arg_list(args or {}).call { await = true }
95+
return git.cli.checkout.track(name).arg_list(args or {}).call { await = true }
9596
end
9697

9798
---@param include_current? boolean

lua/neogit/popups/branch/actions.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ function M.checkout_local_branch(popup)
189189

190190
if target then
191191
if vim.tbl_contains(remote_branches, target) then
192-
git.branch.track(target, popup:get_arguments())
192+
local result = git.branch.track(target, popup:get_arguments())
193+
if result.code > 0 then
194+
notification.error(table.concat(result.stderr, "\n"))
195+
return
196+
end
197+
193198
notification.info("Created local branch " .. target .. " tracking remote")
194199
event.send("BranchCheckout", { branch_name = target })
195200
elseif not vim.tbl_contains(options, target) then

0 commit comments

Comments
 (0)