Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add LIBGIT2_VER_CHECK Macro for Version Comparison#6882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethomson merged 3 commits intolibgit2:mainfromHamedMasafi:main
Sep 30, 2024

Conversation

HamedMasafi
Copy link
Contributor

This merge introduces a LIBGIT2_VERSION_CHECK macro in git2/version.h, similar to Qt's QT_VERSION_CHECK. The macro allows developers to compare the current version of libgit2 at compile time, making it easier to ensure compatibility with specific versions of the library.

Key Changes:

  • Added LIBGIT2_VER_CHECK macro for version comparison.
  • Defined LIBGIT2_VER_NUMBER as a single integer representing the current version.
  • Updated comments to explain the usage of the new macro.

This enhancement will improve the ability to manage version-dependent code more efficiently. Please review the changes and provide feedback!

@ethomson
Copy link
Member

I think that this is generally useful. I'd rather see our version number be human-parseable in a way that reflects the version number. For example:

#define LIBGIT2_VERSION_NUMBER ( \    (LIBGIT2_VER_MAJOR * 1000000) +    (LIBGIT2_VER_MINOR * 10000) +    (LIBGIT2_VER_REVISION * 100) +     LIBGIT2_VER_PATCH )

so that v1.8.2 is1080200.

This also lets callers just say

#if LIBGIT2_VERSION_NUMBER >= 1060300

which seems pretty readable to me. But I think that it's worth offering up a macro in case that'snot very readable. But I think that I would put it as something that evaluates to truthy given a version number. For example:

#define LIBGIT2_VERSION_CHECK(a,b,c) (LIBGIT2_VERSION_NUMBER >= ((a)*1000000)+((b)*10000)+((c)*100))

Then you'd use it as

#if LIBGIT2_VERSION_CHECK(1,6,3)...

For consistency, use LIBGIT2_VERSION_... as the constant name; deprecateLIBGIT2_VER_... names.
@ethomson
Copy link
Member

Thanks! I updated based on my suggestions.

@ethomsonethomson merged commit2ba1730 intolibgit2:mainSep 30, 2024
19 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@HamedMasafi@ethomson

[8]ページ先頭

©2009-2025 Movatter.jp