FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: add ```add``` subcommand by SandrineP · Pull Request #16 · QuantStack/git2cpp · GitHub

Repository navigation

feat: add add subcommand - #16

Merged
ianthomas23 merged 10 commits into
QuantStack:mainfrom
SandrineP:add_sc
Jul 17, 2025
Merged

ianthomas23 merged 10 commits into
QuantStack:mainfrom
SandrineP:add_sc

Conversation

SandrineP commented Jul 15, 2025 •
edited
Loading

Copy link
Copy Markdown
Collaborator

Add the git add sub-command, with the --all flag.

SandrineP marked this pull request as ready for review July 16, 2025 13:28
Comment thread src/wrapper/index_wrapper.cpp Outdated

void index_wrapper::add_impl(std::vector<std::string> patterns)
{
git_strarray array{new char*[patterns.size()], patterns.size()};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This leaks. I think it would be worth having a wrapper of git_strarray, that correctly manages the memory and use it here. It will be useful for other commands anyway.

SandrineP changed the title feat: add 'add' subcommand feat: add add subcommand Jul 16, 2025
Comment thread src/wrapper/index_wrapper.cpp Outdated

void index_wrapper::add_impl(std::vector<std::string> patterns)
{
git_strarray_wrapper array=git_strarray_wrapper(patterns);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
git_strarray_wrapper array=git_strarray_wrapper(patterns);
git_strarray_wrapper array{patterns};

Comment thread src/version.hpp
#define GIT2CPP_VERSION_MAJOR 0
#define GIT2CPP_VERSION_MINOR 0
#define GIT2CPP_VERSION_PATCH 1
#define GIT2CPP_VERSION_PATCH 2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why updating the version?

SandrineP Jul 17, 2025 •
edited
Loading

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The 0.0.2 has been released but we forgot to change it there, so it's to catch up.

Comment thread src/subcommand/add_subcommand.hpp Outdated

private:
bool all_flag = false;
std::vector<std::string> add_files;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Convention: data member names should start with m_ (or p_) so it is easy to distinguish them from local variables.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

m_ stands for "member" and p_ stands for what ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

pointer

Comment thread test/test_add.py Outdated
def test_add(git2cpp_path, all_flag):
with open("./test/mook_file.txt", "x") as f:
pass
f.close()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This line isn't needed as the f will be automatically closed when the with ... block is exited. The same applies to 4 lines below.

Comment thread test/test_add.py

os.remove("./test/mook_file.txt")
os.remove("./test/mook_file_2.txt")
subprocess.run(cmd_add, capture_output=True, text=True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is this line just to undo the add, to leave the test directory at the end the same as it was at the start? If so can you add a comment saying this, otherwise it will look suspicious in future to have this line without any following assert.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, that's the reason why ! I'll write a comment.

ianthomas23 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks @SandrineP!

ianthomas23 merged commit 78f7356 into QuantStack:main Jul 17, 2025
SandrineP deleted the add_sc branch July 17, 2025 13:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL