@@ -39,12 +39,12 @@ annotated_commit_list_wrapper merge_subcommand::resolve_heads(const repository_w
3939 return annotated_commit_list_wrapper (std::move (commits_to_merge));
4040}
4141
42- annotated_commit_list_wrapper resolve_mergeheads (const repository_wrapper& repo, std::vector<git_oid> oid_list)
42+ annotated_commit_list_wrapper resolve_mergeheads (const repository_wrapper& repo, const std::vector<git_oid> oid_list)
4343{
4444 std::vector<annotated_commit_wrapper> commits_to_merge;
4545 commits_to_merge.reserve (oid_list.size ());
4646
47- for (const auto id:oid_list)
47+ for (const auto & id:oid_list)
4848 {
4949 std::optional<annotated_commit_wrapper> commit = repo.find_annotated_commit (id);
5050 if (commit.has_value ())
@@ -55,7 +55,7 @@ annotated_commit_list_wrapper resolve_mergeheads(const repository_wrapper& repo,
5555 return annotated_commit_list_wrapper (std::move (commits_to_merge));
5656}
5757
58- void perform_fastforward (repository_wrapper& repo, const git_oid target_oid, int is_unborn)
58+ void perform_fastforward (repository_wrapper& repo, const git_oid& target_oid, int is_unborn)
5959{
6060 const git_checkout_options ff_checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
6161
@@ -82,13 +82,13 @@ void perform_fastforward(repository_wrapper& repo, const git_oid target_oid, int
8282void merge_subcommand::create_merge_commit (
8383 repository_wrapper& repo,
8484 const index_wrapper& index,
85- std::vector<std::string> m_branches_to_merge ,
85+ const std::vector<std::string> branches_to_merge ,
8686 const annotated_commit_list_wrapper& commits_to_merge,
8787 size_t num_commits_to_merge)
8888{
8989 auto head_ref = repo.head ();
90- auto merge_ref = repo.find_reference_dwim (m_branches_to_merge .front ());
91- auto merge_commit = repo.resolve_local_ref (m_branches_to_merge .front ()).value ();
90+ auto merge_ref = repo.find_reference_dwim (branches_to_merge .front ());
91+ auto merge_commit = repo.resolve_local_ref (branches_to_merge .front ()).value ();
9292
9393 std::vector<commit_wrapper> parents_list;
9494 parents_list.reserve (num_commits_to_merge + 1 );
@@ -110,13 +110,14 @@ void merge_subcommand::create_merge_commit(
110110 std::string msg_target = merge_ref ? merge_ref->short_name () : git_oid_tostr_s (&(merge_commit.oid ()));
111111 msg_target = " \' " + msg_target + " \' " ;
112112 std::string msg = merge_ref ? " Merge branch " : " Merge commit " ;
113- msg.append ( msg_target);
113+ msg.append (msg_target);
114114
115115 repo.create_commit (author_committer_sign_now, msg, std::optional<commit_list_wrapper>(std::move (parents)));
116116
117117 repo.state_cleanup ();
118118}
119119
120+ // This function is used as a callback in git_repository_mergehead_foreach and therefore its type must be git_repository_mergehead_foreach_cb.
120121int populate_list (const git_oid* oid, void * payload)
121122{
122123 auto * l = reinterpret_cast <std::vector<git_oid>*>(payload);
@@ -210,7 +211,7 @@ void merge_subcommand::run()
210211 size_t num_commits_to_merge = commits_to_merge.size ();
211212
212213 std::vector<std::string> branches_to_merge_names;
213- for (auto id:oid_list)
214+ for (const auto & id:oid_list)
214215 {
215216 git_reference_iterator* iter;
216217 git_reference_iterator_new (&iter, repo);
0 commit comments