-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
obj === nothing && return GitHash() | ||
local obj | ||
try | ||
obj = revparse(repo, objname) |
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.
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.
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.
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.
we shouldn't be returning status codes only via the warning display, that's very side-channel and not useful
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.
Ok, should we throw an error then? And let things that call revparseid
do their own try
and catch
?
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.
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.
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 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.
I actually rewrote |
Also, I agree with @ararslan we should get rid of the zero-d hash thing |
Irrelevant now that Simon's PR was merged. |
No description provided.