Skip to content

Add tracking info for log subcommand#106

Merged
ianthomas23 merged 3 commits intoQuantStack:mainfrom
SandrineP:log_tracking
Feb 27, 2026
Merged

Add tracking info for log subcommand#106
ianthomas23 merged 3 commits intoQuantStack:mainfrom
SandrineP:log_tracking

Conversation

@SandrineP
Copy link
Collaborator

@SandrineP SandrineP commented Feb 25, 2026

Fix #90
Add tracking info for log subcommand

@SandrineP SandrineP marked this pull request as ready for review February 25, 2026 15:54
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 98.90110% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.83%. Comparing base (c460fce) to head (8e58bbc).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/subcommand/log_subcommand.cpp 98.90% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ianthomas23
Copy link
Member

The tag and branch information looks really good, and the whitespace between commits is different but not the same as in real git:

Screenshot 2026-02-26 at 10 40 42

@SandrineP
Copy link
Collaborator Author

The tag and branch information looks really good, and the whitespace between commits is different but not the same as in real git:

I looked at the extra newlines, and I thought that there was always a trailing one at the end of the message in git2cpp. So I changed the code a bit and in the tests I made, there was only a newline at the very end that is not there with git. The rest was identical. So I thought it was fine, but apparently not ! I'll have another look.

@SandrineP SandrineP changed the title Add tracking info Add tracking info for log subcommand Feb 26, 2026
}
}

git_strarray_dispose(&tag_names);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 110 to 111
std::string branch_name;
branch_name = branch->name();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::string branch_name;
branch_name = branch->name();
std::string branch_name = branch->name();

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

std::string branch_name(branch->name());

instead, which works for me on macos?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that the return type of branch::name was std::string_view. In that case the correct solution is the line from Ian.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit_oid should be passed by reference insteadof pointer.

}
};

commit_refs get_refs_for_commit(repository_wrapper& repo, const git_oid* commit_oid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit_oid should be passed by reference instead of pointer.

return refs;
}

void print_refs(commit_refs refs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refs should be passed by constant reference.

Copy link
Member

@ianthomas23 ianthomas23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whitespace looks excellent now thanks, and I've checked all of Johan's comments too and this is ready to merge.

I've left the one comment about the branch_name string, feel free to make that change or not.

}

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit_oid parameter should be passed by reference.

@ianthomas23
Copy link
Member

I've confirmed that the extra 2 proposed changes have been implemented, so I am merging.

@ianthomas23 ianthomas23 merged commit 1ba9701 into QuantStack:main Feb 27, 2026
7 of 8 checks passed
@SandrineP SandrineP deleted the log_tracking branch February 27, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce whitespace in log subcommand

3 participants