Skip to content
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. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

At least WARN if revparse{id} fails #20136

Closed
wants to merge 1 commit into from
Closed

Conversation

kshyatt
Copy link
Contributor

@kshyatt kshyatt commented Jan 20, 2017

No description provided.

@kshyatt kshyatt added the libgit2 The libgit2 library or the LibGit2 stdlib module label Jan 20, 2017
@kshyatt kshyatt requested a review from ararslan January 20, 2017 00:32
obj === nothing && return GitHash()
local obj
try
obj = revparse(repo, objname)
Copy link
Contributor

Choose a reason for hiding this comment

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

How frequently does this get called? a try-catch might be fairly expensive. Is there a specific return code for "not found" in git_revparse_single ? I'd prefer returning a Nullable in the not found case if there's a specific return code for it, and throwing any other types of errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tkelman there are a few specific options, see here. It can be not found, ambiguous, invalid spec, or something else.

Copy link
Contributor

Choose a reason for hiding this comment

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

we shouldn't be returning status codes only via the warning display, that's very side-channel and not useful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, should we throw an error then? And let things that call revparseid do their own try and catch?

Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few ways we could go here, and the best option depends on how the surrounding code is structured and which direction we generally want to go in with these binding API's. Are all of the possible not-found conditions errors, or should it be recoverable? Exceptions for control flow in the latter case should be avoided, we could do something with a nullable and/or also return the status code so the callers can decide what to do if things aren't found.

Copy link
Member

@ararslan ararslan left a comment

Choose a reason for hiding this comment

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

I know it's the existing behavior but it seems weird to me to return a zeroed hash from revparseid when there's a problem. Idk, maybe it's fine, but something to think about as we churn through LibGit2. In the meantime, this LGTM.

@simonbyrne
Copy link
Contributor

simonbyrne commented Jan 20, 2017

I actually rewrote revparseid entirely in #20104, so this is probably unnecessary.

@simonbyrne
Copy link
Contributor

Also, I agree with @ararslan we should get rid of the zero-d hash thing

@kshyatt
Copy link
Contributor Author

kshyatt commented Jan 31, 2017

Irrelevant now that Simon's PR was merged.

@kshyatt kshyatt closed this Jan 31, 2017
@kshyatt kshyatt deleted the ksh/revparseidloud branch January 31, 2017 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libgit2 The libgit2 library or the LibGit2 stdlib module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants