@@ -285,10 +285,9 @@ void repository_wrapper::reset(const object_wrapper& target, git_reset_t reset_t
285285
286286size_t repository_wrapper::shallow_depth_from_head() const
287287{
288- size_t depth = 0;
289288 if (!this->is_shallow())
290289 {
291- return depth ;
290+ return 0u ;
292291 }
293292
294293 std::string git_path = this->git_path();
@@ -307,44 +306,44 @@ size_t repository_wrapper::shallow_depth_from_head() const
307306 }
308307 }
309308
310- if (boundaries_list.size()==0 )
309+ if (boundaries_list.size() == 0u )
311310 {
312- return depth ;
311+ return 0u ;
313312 }
314313
315314 commit_wrapper head_commit = this->find_commit("HEAD");
316315 commit_list_wrapper commits_list = head_commit.get_parents_list();
317- std::vector<size_t> depth_list(commits_list.size(), 0 );
318- std::vector<size_t> final_depths(boundaries_list.size(), 0 );
319- bool has_parent = commits_list.size() > 0 ;
316+ std::vector<size_t> depth_list(commits_list.size(), 1u );
317+ std::vector<size_t> final_depths(boundaries_list.size(), 1u );
318+ bool has_parent = commits_list.size() > 0u ;
320319 while (has_parent)
321320 {
322321 has_parent = false;
323322 std::vector<commit_wrapper> temp_commits_list;
324323 std::vector<size_t> temp_depth_list;
325324 commit_list_wrapper parent_list({});
326325
327- for (size_t i = 0 ; i < commits_list.size(); i++)
326+ for (size_t i = 0u ; i < commits_list.size(); i++)
328327 {
329328 const commit_wrapper& commit = commits_list[i];
330329 size_t depth = depth_list[i];
331330 const git_oid& oid = commit.oid();
332331 bool is_boundary = std::find_if(boundaries_list.cbegin(), boundaries_list.cend(), [oid](const git_oid& val) {return git_oid_equal(&oid, &val);}) != boundaries_list.cend();
333332 if (is_boundary)
334333 {
335- final_depths.push_back(depth + 1 );
334+ final_depths.push_back(depth + 1u );
336335 }
337336 else
338337 {
339338 parent_list = commit.get_parents_list();
340- if (parent_list.size() > 0 )
339+ if (parent_list.size() > 0u )
341340 {
342341 has_parent = true;
343- for (size_t j = 0 ; parent_list.size(); j++)
342+ for (size_t j = 0u ; parent_list.size(); j++)
344343 {
345344 const commit_wrapper& c = parent_list[j];
346345 temp_commits_list.push_back(std::move(const_cast<commit_wrapper&>(c)));
347- temp_depth_list.push_back(depth + 1 );
346+ temp_depth_list.push_back(depth + 1u );
348347 }
349348 }
350349 }
@@ -353,7 +352,7 @@ size_t repository_wrapper::shallow_depth_from_head() const
353352 commits_list = commit_list_wrapper(std::move(temp_commits_list));
354353 }
355354
356- depth = *std::max_element(final_depths.begin(), final_depths.end());
355+ std::size_t depth = *std::max_element(final_depths.begin(), final_depths.end());
357356 return depth;
358357}
359358
0 commit comments