Skip to content

Difference in behaviour between git ls-remote and libgit2 equivalent #6275

@apnadkarni

Description

@apnadkarni

I'm not sure if this is a bug or a by-design difference from the official git. The official git implementation includes a peeled entry (with ^{} suffix) for refs to blobs. The libgit2 implementation (git_remote_ls -> local_ls) does not due to this check which only attempts to peel if the ref is under the refs/tags directory. In the example below, the ref is under refs/blobs directory.

Only bringing it to your notice in case this is a bug and not an intended difference.

Reproduction steps

Console session:

D:\Temp>git clone \src\libgit2\tests\resources\testrepo.git lg2-test
Cloning into 'lg2-test'...
done.

D:\Temp>cd lg2-test

D:\Temp\lg2-test>git ls-remote origin
a65fedf39aefe402d3bb6e24df4d4f5fe4547750        HEAD
521d87c1ec3aef9824daf6d96cc0ae3710766d91        refs/blobs/annotated_tag_to_blob
1385f264afb75a56a5bec74243be9b367ba4ca08        refs/blobs/annotated_tag_to_blob^{}
a4a7dce85cf63874e984719f4fdd239f5145052f        refs/heads/br2
a4a7dce85cf63874e984719f4fdd239f5145052f        refs/heads/cannot-fetch
e90810b8df3e80c413d903f631643c716887138d        refs/heads/chomped
258f0e2a959a364e40ed6603d5d44fbb24765b10        refs/heads/haacked
a65fedf39aefe402d3bb6e24df4d4f5fe4547750        refs/heads/master
a65fedf39aefe402d3bb6e24df4d4f5fe4547750        refs/heads/not-good
41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9        refs/heads/packed
4a202b346bb0fb0db7eff3cffeb3c70babbd2045        refs/heads/packed-test
763d71aadf09a7951596c9746c024e7eece7c7af        refs/heads/subtrees
e90810b8df3e80c413d903f631643c716887138d        refs/heads/test
9fd738e8f7967c078dceed8190330fc8648ee56a        refs/heads/track-local
e90810b8df3e80c413d903f631643c716887138d        refs/heads/trailing
8496071c1b46c854b31185ea97743be6a8774479        refs/heads/with-empty-log
d07b0f9a8c89f1d9e74dc4fce6421dec5ef8a659        refs/notes/fanout
be3563ae3f795b2b4353bcce3a527ad0a4f7f644        refs/remotes/test/master
521d87c1ec3aef9824daf6d96cc0ae3710766d91        refs/tags/annotated_tag_to_blob
1385f264afb75a56a5bec74243be9b367ba4ca08        refs/tags/annotated_tag_to_blob^{}
7b4384978d2493e851f9cca7858815fac9b10980        refs/tags/e90810b
e90810b8df3e80c413d903f631643c716887138d        refs/tags/e90810b^{}
849a5e34a26815e821f865b8479f5815a47af0fe        refs/tags/hard_tag
a65fedf39aefe402d3bb6e24df4d4f5fe4547750        refs/tags/hard_tag^{}
1385f264afb75a56a5bec74243be9b367ba4ca08        refs/tags/point_to_blob
4a23e2e65ad4e31c4c9db7dc746650bfad082679        refs/tags/taggerless
e90810b8df3e80c413d903f631643c716887138d        refs/tags/taggerless^{}
b25fa35b38051e4ae45d4222e795f9df2e43f1d1        refs/tags/test
e90810b8df3e80c413d903f631643c716887138d        refs/tags/test^{}
849a5e34a26815e821f865b8479f5815a47af0fe        refs/tags/wrapped_tag
a65fedf39aefe402d3bb6e24df4d4f5fe4547750        refs/tags/wrapped_tag^{}

D:\Temp\lg2-test>..\lg2-debug\lg2.exe ls-remote origin
a65fedf39aefe402d3bb6e24df4d4f5fe4547750        HEAD
521d87c1ec3aef9824daf6d96cc0ae3710766d91        refs/blobs/annotated_tag_to_blob
a4a7dce85cf63874e984719f4fdd239f5145052f        refs/heads/br2
a4a7dce85cf63874e984719f4fdd239f5145052f        refs/heads/cannot-fetch
e90810b8df3e80c413d903f631643c716887138d        refs/heads/chomped
258f0e2a959a364e40ed6603d5d44fbb24765b10        refs/heads/haacked
a65fedf39aefe402d3bb6e24df4d4f5fe4547750        refs/heads/master
a65fedf39aefe402d3bb6e24df4d4f5fe4547750        refs/heads/not-good
41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9        refs/heads/packed
4a202b346bb0fb0db7eff3cffeb3c70babbd2045        refs/heads/packed-test
763d71aadf09a7951596c9746c024e7eece7c7af        refs/heads/subtrees
e90810b8df3e80c413d903f631643c716887138d        refs/heads/test
9fd738e8f7967c078dceed8190330fc8648ee56a        refs/heads/track-local
e90810b8df3e80c413d903f631643c716887138d        refs/heads/trailing
8496071c1b46c854b31185ea97743be6a8774479        refs/heads/with-empty-log
d07b0f9a8c89f1d9e74dc4fce6421dec5ef8a659        refs/notes/fanout
be3563ae3f795b2b4353bcce3a527ad0a4f7f644        refs/remotes/test/master
521d87c1ec3aef9824daf6d96cc0ae3710766d91        refs/tags/annotated_tag_to_blob
1385f264afb75a56a5bec74243be9b367ba4ca08        refs/tags/annotated_tag_to_blob^{}
7b4384978d2493e851f9cca7858815fac9b10980        refs/tags/e90810b
e90810b8df3e80c413d903f631643c716887138d        refs/tags/e90810b^{}
849a5e34a26815e821f865b8479f5815a47af0fe        refs/tags/hard_tag
a65fedf39aefe402d3bb6e24df4d4f5fe4547750        refs/tags/hard_tag^{}
1385f264afb75a56a5bec74243be9b367ba4ca08        refs/tags/point_to_blob
4a23e2e65ad4e31c4c9db7dc746650bfad082679        refs/tags/taggerless
e90810b8df3e80c413d903f631643c716887138d        refs/tags/taggerless^{}
b25fa35b38051e4ae45d4222e795f9df2e43f1d1        refs/tags/test
e90810b8df3e80c413d903f631643c716887138d        refs/tags/test^{}
849a5e34a26815e821f865b8479f5815a47af0fe        refs/tags/wrapped_tag

Expected behavior

The lg2 output should include

1385f264afb75a56a5bec74243be9b367ba4ca08        refs/blobs/annotated_tag_to_blob^{}

just as git does.

Actual behavior

Above line is not included.

Version of libgit2 (release number or SHA1)

1.4.2

Operating system(s) tested

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions