Skip to content

Commit dded9a6

Browse files
committed
Code cleanup
1 parent 255c1c0 commit dded9a6

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

src/subcommand/fetch_subcommand.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ void fetch_subcommand::run()
4646
fetch_opts.depth = GIT_FETCH_DEPTH_UNSHALLOW;
4747
}
4848
else if (m_deepen > 0)
49-
{
50-
size_t shallow_size = repo.shallow_depth_from_head();
51-
fetch_opts.depth = shallow_size + m_deepen;
52-
}
49+
{
50+
size_t shallow_size = repo.shallow_depth_from_head();
51+
fetch_opts.depth = shallow_size + m_deepen;
52+
}
5353
else
5454
{
5555
fetch_opts.depth = m_depth;

src/wrapper/commit_wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ commit_list_wrapper commit_wrapper::get_parents_list() const
3737
{
3838
git_commit* parent;
3939
git_commit_parent(&parent, *this, i);
40-
parents_list.push_back(std::move(commit_wrapper(parent)));
40+
parents_list.push_back(commit_wrapper(parent));
4141
}
4242
return commit_list_wrapper(std::move(parents_list));
4343
}

src/wrapper/repository_wrapper.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,13 @@ size_t repository_wrapper::shallow_depth_from_head() const
316316
commit_list_wrapper commits_list = head_commit.get_parents_list();
317317
std::vector<size_t> depth_list(commits_list.size(), 0);
318318
std::vector<size_t> final_depths(boundaries_list.size(), 0);
319-
size_t has_parent = commits_list.size() > 0;
319+
bool has_parent = commits_list.size() > 0;
320320
while (has_parent)
321321
{
322-
has_parent = 0;
322+
has_parent = false;
323323
std::vector<commit_wrapper> temp_commits_list;
324324
std::vector<size_t> temp_depth_list;
325325
commit_list_wrapper parent_list({});
326-
std::vector<size_t> has_parent_list;
327326

328327
for (size_t i = 0; i < commits_list.size(); i++)
329328
{
@@ -340,24 +339,18 @@ size_t repository_wrapper::shallow_depth_from_head() const
340339
parent_list = commit.get_parents_list();
341340
if (parent_list.size() > 0)
342341
{
343-
has_parent_list.push_back(1);
342+
has_parent = true;
344343
for (size_t j = 0; parent_list.size(); j++)
345344
{
346345
const commit_wrapper& c = parent_list[j];
347346
temp_commits_list.push_back(std::move(const_cast<commit_wrapper&>(c)));
348347
temp_depth_list.push_back(depth + 1);
349348
}
350349
}
351-
else
352-
{
353-
has_parent_list.push_back(0);
354-
}
355350
}
356351
}
357352
depth_list = temp_depth_list;
358353
commits_list = commit_list_wrapper(std::move(temp_commits_list));
359-
auto has_parent_iter = std::max_element(has_parent_list.begin(), has_parent_list.end());
360-
has_parent = has_parent_iter != has_parent_list.end() ? *has_parent_iter : 0u;
361354
}
362355

363356
depth = *std::max_element(final_depths.begin(), final_depths.end());

0 commit comments

Comments
 (0)