Skip to content

Commit f2c5be0

Browse files
committed
upstream push to a branch with a different name
1 parent 89a2df9 commit f2c5be0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lua/neogit/popups/push/actions.lua

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ local function push_to(args, remote, branch, opts)
3131
logger.debug("Pushing to " .. name)
3232
notification.info("Pushing to " .. name)
3333

34+
local current_branch = git.branch.current()
35+
if current_branch ~= branch then
36+
branch = current_branch .. ":" .. branch
37+
end
3438
local res = git.push.push_interactive(remote, branch, args)
3539

3640
-- Inform the user about missing permissions
@@ -83,9 +87,12 @@ function M.to_upstream(popup)
8387
remote, branch = git.branch.parse_remote_branch(upstream)
8488
else
8589
set_upstream = true
86-
branch = git.branch.current()
87-
remote = git.branch.upstream_remote()
88-
or FuzzyFinderBuffer.new(git.remote.list()):open_async { prompt_prefix = "remote" }
90+
local target = FuzzyFinderBuffer.new(git.refs.list_remote_branches()):open_async {
91+
prompt_prefix = "push",
92+
}
93+
if target then
94+
remote, branch = git.branch.parse_remote_branch(target)
95+
end
8996
end
9097

9198
if remote then

0 commit comments

Comments
 (0)