Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Code cleanup
  • Loading branch information
JohanMabille committed Jan 13, 2026
commit dded9a63299ba25bd0c2286d7c7474d01bcc8bfd
8 changes: 4 additions & 4 deletions src/subcommand/fetch_subcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ void fetch_subcommand::run()
fetch_opts.depth = GIT_FETCH_DEPTH_UNSHALLOW;
}
else if (m_deepen > 0)
{
size_t shallow_size = repo.shallow_depth_from_head();
fetch_opts.depth = shallow_size + m_deepen;
}
{
size_t shallow_size = repo.shallow_depth_from_head();
fetch_opts.depth = shallow_size + m_deepen;
}
else
{
fetch_opts.depth = m_depth;
Expand Down
2 changes: 1 addition & 1 deletion src/wrapper/commit_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ commit_list_wrapper commit_wrapper::get_parents_list() const
{
git_commit* parent;
git_commit_parent(&parent, *this, i);
parents_list.push_back(std::move(commit_wrapper(parent)));
parents_list.push_back(commit_wrapper(parent));
}
return commit_list_wrapper(std::move(parents_list));
}
13 changes: 3 additions & 10 deletions src/wrapper/repository_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,13 @@ size_t repository_wrapper::shallow_depth_from_head() const
commit_list_wrapper commits_list = head_commit.get_parents_list();
std::vector<size_t> depth_list(commits_list.size(), 0);
std::vector<size_t> final_depths(boundaries_list.size(), 0);
size_t has_parent = commits_list.size() > 0;
bool has_parent = commits_list.size() > 0;
while (has_parent)
{
has_parent = 0;
has_parent = false;
std::vector<commit_wrapper> temp_commits_list;
std::vector<size_t> temp_depth_list;
commit_list_wrapper parent_list({});
std::vector<size_t> has_parent_list;

for (size_t i = 0; i < commits_list.size(); i++)
{
Expand All @@ -340,24 +339,18 @@ size_t repository_wrapper::shallow_depth_from_head() const
parent_list = commit.get_parents_list();
if (parent_list.size() > 0)
{
has_parent_list.push_back(1);
has_parent = true;
for (size_t j = 0; parent_list.size(); j++)
{
const commit_wrapper& c = parent_list[j];
temp_commits_list.push_back(std::move(const_cast<commit_wrapper&>(c)));
temp_depth_list.push_back(depth + 1);
}
}
else
{
has_parent_list.push_back(0);
}
}
}
depth_list = temp_depth_list;
commits_list = commit_list_wrapper(std::move(temp_commits_list));
auto has_parent_iter = std::max_element(has_parent_list.begin(), has_parent_list.end());
has_parent = has_parent_iter != has_parent_list.end() ? *has_parent_iter : 0u;
}

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