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

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethomson merged 5 commits intolibgit2:mainfrommathworks:pr_6724
Dec 12, 2024

Conversation

lrm29
Copy link
Contributor

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.

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) {
Copy link
ContributorAuthor

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?

ethomson reacted with thumbs up emoji
@@ -520,13 +520,38 @@ int git_object_lookup_bypath(
return error;
}

int git_object__abbrev_length(int *out, git_repository *repo)
Copy link
Member

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 thegit_repository group, instead ofgit_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.

Copy link
ContributorAuthor

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 :)

ethomson reacted with thumbs up emoji
@ethomson
Copy link
Member

Wow, there's some fun things going on here in git compatibility land:

  1. core.abbrev=0 (an integer value) fails, butcore.abbrev=false (a boolean value) succeeds.
  2. core.abbrev=999 succeeds (clamping to the max oid length)

:sigh:

Copy link
Member

@ethomsonethomson left a 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.

@lrm29
Copy link
ContributorAuthor

Wow, there's some fun things going on here in git compatibility land:

1. `core.abbrev=0` (an integer value) fails, but `core.abbrev=false` (a boolean value) succeeds.2. `core.abbrev=999` succeeds (clamping to the max oid length)

:sigh:

Good spots.

  1. I missed that, git has agit_parse_maybe_bool_text which doesn't allow 0.

  2. Erroring was the existing libgit2 behaviour right? But Git compatibility wins...

@ethomson
Copy link
Member

But Git compatibility wins...

We aim to be bug-for-bug compatible. 🤣 😭

@ethomson
Copy link
Member

Thanks for the fix!

@ethomsonethomson merged commit0bb7d45 intolibgit2:mainDec 12, 2024
19 checks passed
@lrm29lrm29 deleted the pr_6724 branchDecember 12, 2024 18:35
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ethomsonethomsonethomson approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

git_object_short_id fails with core.abbrev string values
2 participants
@lrm29@ethomson

[8]ページ先頭

©2009-2025 Movatter.jp