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

Add ```checkout file``` by SandrineP · Pull Request #165 · QuantStack/git2cpp · GitHub

Repository navigation

Add checkout file - #165

Merged
ianthomas23 merged 8 commits into
QuantStack:mainfrom
SandrineP:checkout_file
Jun 12, 2026
Merged

ianthomas23 merged 8 commits into
QuantStack:mainfrom
SandrineP:checkout_file

Conversation

Copy link
Copy Markdown
Collaborator

Add checkout file

codecov Bot commented Jun 2, 2026 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.95575% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.78%. Comparing base (4bdec5e) to head (3cb4e11).
⚠️ Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
src/subcommand/checkout_subcommand.cpp 84.40% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #165      +/-   ##
==========================================
- Coverage   88.55%   86.78%   -1.78%     
==========================================
  Files          62       62              
  Lines        2893     2974      +81     
  Branches      361      372      +11     
==========================================
+ Hits         2562     2581      +19     
- Misses        331      393      +62     

☔ View full report in Codecov by Harness.
📢 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.

SandrineP marked this pull request as ready for review June 3, 2026 08:46

Copy link
Copy Markdown
Member

If you do a checkout with 2 positional arguments and the first is a branch or tag:

git2cpp checkout v1.0 v2.0

then it looks like the second argument is ignored. Should we explicitly check for this and error out rather than silently ignoring the second arg?

Copy link
Copy Markdown
Member

then it looks like the second argument is ignored. Should we explicitly check for this and error out rather than silently ignoring the second arg?

That would be consistent with git behavior.

JohanMabille 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

LGTM once the error handling is added.

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

Just a couple of comments about the tests.

Comment thread test/test_checkout.py Outdated
second_file.write_text("second content")

add_cmd = [git2cpp_path, "add", "second.txt"]
subprocess.run(add_cmd, cwd=tmp_path, 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

We should either explicitly check the returncode is zero, or add a check=True to this subprocess call.

Comment thread test/test_checkout.py Outdated
add_cmd = [git2cpp_path, "add", "second.txt"]
subprocess.run(add_cmd, cwd=tmp_path, text=True)
commit_cmd = [git2cpp_path, "commit", "-m", "Add second file"]
subprocess.run(commit_cmd, cwd=tmp_path, 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

Check return code here too.

Comment thread test/test_checkout.py Outdated
second_file.write_text("second content")

add_cmd = [git2cpp_path, "add", "second.txt"]
subprocess.run(add_cmd, cwd=tmp_path, 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

Check return code, and 2 lines below.

Comment thread src/subcommand/checkout_subcommand.cpp Outdated
}
}

void checkout_subcommand::checkout_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

Could be renamed checkout_head_files

Comment thread src/subcommand/checkout_subcommand.cpp Outdated
throw_if_error(git_checkout_head(repo, &options));
}

void checkout_subcommand::checkout_paths(

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

Could be renamed checkout_tree_files or checkout_ref_files

Comment thread src/subcommand/checkout_subcommand.cpp Outdated
Comment on lines +151 to +154
return;
}

if (!pathspecs.empty())

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

Prefer else if instead of multi return statements. (Early return to handle error / specific case is usually ok, but it makes it harder to nuderstand the code when used to encode the logic).

Comment thread src/subcommand/checkout_subcommand.cpp Outdated
Comment on lines +173 to +177
return;
}
catch (const git_exception& e)

// Else treat as files
for (const auto& p : pathspecs)

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

Here too prefer an else branch rather than a return statement.

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

LGTM. The 'detached HEAD' information is as I'd expect for my usual workflow.

ianthomas23 merged commit 58f0944 into QuantStack:main Jun 12, 2026
5 of 7 checks passed
SandrineP deleted the checkout_file branch June 12, 2026 10:12
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