Skip to content

odb_read_prefix: reset error in backends loop#4264

Merged
pks-t merged 1 commit intomasterfrom
ethomson/read_prefix
Jun 12, 2017
Merged

odb_read_prefix: reset error in backends loop#4264
pks-t merged 1 commit intomasterfrom
ethomson/read_prefix

Conversation

@ethomson
Copy link
Copy Markdown
Member

When looking for an object by prefix, we query all the backends so that we can ensure that there is no ambiguity. We need to reset the error value between backends; otherwise the first backend may find an object by prefix, but subsequent backends may not. If we do not reset the error value then it will remain at GIT_ENOTFOUND and read_prefix_1 will fail, despite having actually found an object.

LibGit2Sharp creates such a scenario in its tests: it sets up its own custom ODB backend, then adds an object and looks that object up again by a prefix.

When looking for an object by prefix, we query all the backends so that
we can ensure that there is no ambiguity.  We need to reset the `error`
value between backends; otherwise the first backend may find an object
by prefix, but subsequent backends may not.  If we do not reset the
`error` value then it will remain at `GIT_ENOTFOUND` and `read_prefix_1`
will fail, despite having actually found an object.
@pks-t pks-t mentioned this pull request Jun 12, 2017
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jun 12, 2017

Looks good as is. I wrote a test which segfaults due to this issue in #4265.

@pks-t pks-t merged commit 2ade8fb into master Jun 12, 2017
@ethomson ethomson deleted the ethomson/read_prefix branch January 9, 2019 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants