-
Notifications
You must be signed in to change notification settings - Fork 2.5k
object: git_object_short_id fails with core.abbrev string values #6944
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 our terms of service and privacy statement. 8000 We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
git_error_set(GIT_ERROR_CONFIG, "invalid oid abbreviation setting: '%d'", len); | ||
return -1; | ||
if ((size_t)len == oid_hexsize) { | ||
if ((error = git_oid_cpy(&id, &obj->cached.oid)) < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we early return here?
src/libgit2/object.c
Outdated
@@ -520,13 +520,38 @@ int git_object_lookup_bypath( | |||
return error; | |||
} | |||
|
|||
int git_object__abbrev_length(int *out, git_repository *repo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that probably this should be in the git_repository
group, instead of git_object
. (It's really about the repository's abbreviation settings.) This is a minor nit, and I've kept you waiting on a review for a long time, so I'm happy to make this change later today if you prefer. 🙏
Thanks for investigating and fixing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will move to git_repository__abbrev_length. I just happened to run into this issue and used it to get more practice with C, no rush :)
Wow, there's some fun things going on here in git compatibility land:
:sigh: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some notes after poking with this in the context of git itself.
Good spots.
|
We aim to be bug-for-bug compatible. 🤣 😭 |
Thanks for the fix! |
Fixes #6878.
Not sure if I went to far here, I noticed core.abbrev was used by diff_print.c. If the user sets core.abbrev to an integer outside of the allowed range that will now error.
I also added GIT_ABBREV_MINIMUM, which Git sets to 4. libgit2 was allowing anything above zero.