Add tracking info for log subcommand#106
Conversation
cb306a0 to
05a30ec
Compare
05a30ec to
81992bd
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #106 +/- ##
==========================================
+ Coverage 86.18% 86.83% +0.65%
==========================================
Files 60 60
Lines 2186 2340 +154
Branches 244 276 +32
==========================================
+ Hits 1884 2032 +148
- Misses 302 308 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I looked at the extra |
src/subcommand/log_subcommand.cpp
Outdated
| } | ||
| } | ||
|
|
||
| git_strarray_dispose(&tag_names); |
There was a problem hiding this comment.
This is not exception-safe. However, we cannot use the git_strarray_wrapper here, since this class actually wraps a git_strarray whose elements point to already allocating strings (and thus, git_strarray_dispose is not called in the destructor to avoid double deletion).
Which leads me to think that the current git_strarray_wrapper is probably badly named. And that we should have a git_strarray_wrapper that frees both git_strarray elements and the array itself.
But this implies refactoring and goes beyond the scope of this PR, so let's add a TODO here and open an issue to track it when we merge this PR.
src/subcommand/log_subcommand.cpp
Outdated
| std::string branch_name; | ||
| branch_name = branch->name(); |
There was a problem hiding this comment.
| std::string branch_name; | |
| branch_name = branch->name(); | |
| std::string branch_name = branch->name(); |
There was a problem hiding this comment.
I wrote it this way because it's not happy with the one line option:
error: conversion from 'std::string_view' {aka 'std::basic_string_view<char>'} to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
There was a problem hiding this comment.
How about
std::string branch_name(branch->name());instead, which works for me on macos?
There was a problem hiding this comment.
I missed that the return type of branch::name was std::string_view. In that case the correct solution is the line from Ian.
src/subcommand/log_subcommand.cpp
Outdated
| return tags; | ||
| } | ||
|
|
||
| std::vector<std::string> get_branches_for_commit(repository_wrapper& repo, git_branch_t type, const git_oid* commit_oid, const std::string exclude_branch) |
There was a problem hiding this comment.
commit_oid should be passed by reference insteadof pointer.
src/subcommand/log_subcommand.cpp
Outdated
| } | ||
| }; | ||
|
|
||
| commit_refs get_refs_for_commit(repository_wrapper& repo, const git_oid* commit_oid) |
There was a problem hiding this comment.
commit_oid should be passed by reference instead of pointer.
src/subcommand/log_subcommand.cpp
Outdated
| return refs; | ||
| } | ||
|
|
||
| void print_refs(commit_refs refs) |
There was a problem hiding this comment.
refs should be passed by constant reference.
cb729f2 to
807cb09
Compare
src/subcommand/log_subcommand.cpp
Outdated
| } | ||
|
|
||
| void print_commit(const commit_wrapper& commit, std::string m_format_flag) | ||
| std::vector<std::string> get_tags_for_commit(repository_wrapper& repo, const git_oid* commit_oid) |
There was a problem hiding this comment.
The commit_oid parameter should be passed by reference.
|
I've confirmed that the extra 2 proposed changes have been implemented, so I am merging. |

Fix #90
Add tracking info for log subcommand