Skip to content

refs: do not use peeled OID if peeling to a tag - #4367

Merged
ethomson merged 1 commit into
libgit2:masterfrom
pks-t:pks/peel-peeled-to-tag
Oct 6, 2017
Merged

refs: do not use peeled OID if peeling to a tag#4367
ethomson merged 1 commit into
libgit2:masterfrom
pks-t:pks/peel-peeled-to-tag

Conversation

@pks-t

@pks-t pks-t commented Oct 6, 2017

Copy link
Copy Markdown
Member

If a reference stored inside of the packed-refs file does not directly
point to a commit object, it will always have a fully-peeled value
pointing to the underlying commit object. If we peel a reference to an
object, we will use that peeled value to speed up resolving the object.
This works as intended for all objects, except for annotated tags.

As a reference for an annotated tag does not directly point to the
commit but instead to the tag object, the packed-refs file will have an
accomodating fully-peeled object ID pointing to the commit of that tag.
When we use that fully-peeled OID pointing to that commit, though, we
obviously cannot peel that to the tag anymore.

Fix this issue by not using the fully-peeled OID whenever we want to
peel to a tag. Note that this does not include the case where we want to
resolve to any object type. Existing code may make use from the fact
that we resolve those to commit objects instead of tag objects, even
though that behaviour is inconsistent between packed and loose
references. Furthermore, some tests of ours make the assumption that we
in fact resolve those references to a commit.

@pks-t

pks-t commented Oct 6, 2017

Copy link
Copy Markdown
Member Author

Fixes #4355

If a reference stored in a packed-refs file does not directly point to a
commit, tree or blob, the packed-refs file will also will include a
fully-peeled OID pointing to the first underlying object of that type.
If we try to peel a reference to an object, we will use that peeled OID
to speed up resolving the object.

As a reference for an annotated tag does not directly point to a commit,
tree or blob but instead to the tag object, the packed-refs file will
have an accomodating fully-peeled OID pointing to the object referenced
by that tag. When we use the fully-peeled OID pointing to the referenced
object when peeling, we obviously cannot peel that to the tag anymore.

Fix this issue by not using the fully-peeled OID whenever we want to
peel to a tag. Note that this does not include the case where we want to
resolve to _any_ object type. Existing code may make use from the fact
that we resolve those to commit objects instead of tag objects, even
though that behaviour is inconsistent between packed and loose
references. Furthermore, some tests of ours make the assumption that we
in fact resolve those references to a commit.
@pks-t
pks-t force-pushed the pks/peel-peeled-to-tag branch from f0eb73b to b112b1e Compare October 6, 2017 10:52
@ethomson
ethomson merged commit e2e3943 into libgit2:master Oct 6, 2017
@ethomson

ethomson commented Oct 6, 2017

Copy link
Copy Markdown
Member

Thanks!

@pks-t
pks-t deleted the pks/peel-peeled-to-tag branch November 11, 2017 20:33
@pks-t pks-t added the backport label Jan 11, 2018
@pks-t pks-t mentioned this pull request Jan 12, 2018
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