@@ -497,18 +497,30 @@ function GitTool.push(remote, branch, force, tags, tag_name)
497497 if force then
498498 cmd = cmd .. " --force"
499499 end
500- if remote then
501- cmd = cmd .. " " .. vim .fn .shellescape (remote )
502- end
503- if branch then
504- cmd = cmd .. " " .. vim .fn .shellescape (branch )
505- end
506- if tags then
507- cmd = cmd .. " --tags"
508- end
509- if tag_name then
500+
501+ -- Handle tag pushing - single tag takes priority over all tags
502+ if tag_name and vim .trim (tag_name ) ~= " " then
503+ -- Push single tag: git push origin tag_name
504+ if remote then
505+ cmd = cmd .. " " .. vim .fn .shellescape (remote )
506+ end
510507 cmd = cmd .. " " .. vim .fn .shellescape (tag_name )
508+ elseif tags then
509+ -- Push all tags: git push origin --tags
510+ if remote then
511+ cmd = cmd .. " " .. vim .fn .shellescape (remote )
512+ end
513+ cmd = cmd .. " --tags"
514+ else
515+ -- Regular branch push: git push origin branch
516+ if remote then
517+ cmd = cmd .. " " .. vim .fn .shellescape (remote )
518+ end
519+ if branch then
520+ cmd = cmd .. " " .. vim .fn .shellescape (branch )
521+ end
511522 end
523+
512524 return execute_git_command (cmd )
513525end
514526
@@ -528,18 +540,28 @@ function GitTool.push_async(remote, branch, force, set_upstream, tags, tag_name,
528540 if set_upstream then
529541 table.insert (cmd , " --set-upstream" )
530542 end
531- if tags then
532- table.insert (cmd , " --tags" )
533- end
534- if tag_name then
535- table.insert (cmd , " tag" )
543+
544+ -- Handle tag pushing - single tag takes priority over all tags
545+ if tag_name and vim .trim (tag_name ) ~= " " then
546+ -- Push single tag: git push origin tag_name
547+ if remote then
548+ table.insert (cmd , remote )
549+ end
536550 table.insert (cmd , tag_name )
537- end
538- if remote then
539- table.insert (cmd , remote )
540- end
541- if branch then
542- table.insert (cmd , branch )
551+ elseif tags then
552+ -- Push all tags: git push origin --tags
553+ if remote then
554+ table.insert (cmd , remote )
555+ end
556+ table.insert (cmd , " --tags" )
557+ else
558+ -- Regular branch push with optional upstream setting
559+ if remote then
560+ table.insert (cmd , remote )
561+ end
562+ if branch then
563+ table.insert (cmd , branch )
564+ end
543565 end
544566
545567 local stdout_lines = {}
0 commit comments