FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add branches to push subcommand by SandrineP · Pull Request #126 · QuantStack/git2cpp · GitHub

Repository navigation

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .cpp  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 17, 2026
commit 4775663d3fff3c4d7312270b3c7a2b7c4796fab7
15 changes: 10 additions & 5 deletions src/subcommand/push_subcommand.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ push_subcommand::push_subcommand(const libgit2_object&, CLI::App& app)
auto* sub = app.add_subcommand("push", "Update remote refs along with associated objects");

sub->add_option("<remote>", m_remote_name, "The remote to push to")->default_val("origin");
sub->add_option("<refspec>", m_refspecs, "The refspec(s) to push")->expected(0,-1);
sub->add_option("<refspec>", m_refspecs, "The refspec(s) to push")->expected(0, -1);
sub->add_flag(
"--all,--branches",
m_branches_flag,
Expand Down Expand Up @@ -97,7 +97,10 @@ std::unordered_map<std::string, git_oid> get_remotes(repository_wrapper& repo, s
return remotes_oids;
}

std::unordered_map<std::string, git_oid> diff_branches(std::unordered_map<std::string, git_oid> remotes_before_push, std::unordered_map<std::string, git_oid> remotes_after_push)
std::unordered_map<std::string, git_oid> diff_branches(
std::unordered_map<std::string, git_oid> remotes_before_push,
std::unordered_map<std::string, git_oid> remotes_after_push
)
{
std::unordered_map<std::string, git_oid> new_branches;
for (const auto& br : remotes_after_push)
Expand All @@ -112,7 +115,8 @@ std::unordered_map<std::string, git_oid> diff_branches(std::unordered_map<std::s
return new_branches;
}

std::pair<std::vector<std::string>, std::vector<std::string>> split_refspecs(std::vector<std::string> refspecs, std::unordered_map<std::string, git_oid> new_branches)
std::pair<std::vector<std::string>, std::vector<std::string>>
split_refspecs(std::vector<std::string> refspecs, std::unordered_map<std::string, git_oid> new_branches)
{
std::vector<std::string> new_pushed_refspecs;
std::vector<std::string> existing_refspecs;
Expand All @@ -132,7 +136,8 @@ std::pair<std::vector<std::string>, std::vector<std::string>> split_refspecs(std
return std::make_pair(new_pushed_refspecs, existing_refspecs);
}

std::pair<std::string, std::string> get_branch_names(repository_wrapper& repo, std::string remote_name, std::string refspec)
std::pair<std::string, std::string>
get_branch_names(repository_wrapper& repo, std::string remote_name, std::string refspec)
{
std::optional<std::string> upstream_opt = repo.branch_upstream_name(refspec);
std::string remote_branch = refspec;
Expand Down Expand Up @@ -170,7 +175,7 @@ void push_subcommand::run()

fill_refspec(repo);
std::vector<std::string> refspecs_push;
for (auto refspec:m_refspecs)
for (auto refspec : m_refspecs)
{
refspecs_push.push_back("refs/heads/" + refspec);
}
Expand Down

Back | FazBrowse Home | New Git URL