Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/ReferenceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ReferenceFixture : BaseFixture
{
"refs/heads/br2", "refs/heads/deadbeef", "refs/heads/master", "refs/heads/packed", "refs/heads/packed-test",
"refs/heads/test", "refs/notes/answer", "refs/notes/answer2", "refs/notes/commits", "refs/tags/e90810b",
"refs/tags/lw", "refs/tags/point_to_blob", "refs/tags/test"
"refs/tags/lw", "refs/tags/point_to_blob", "refs/tags/tag_without_tagger", "refs/tags/test"
};

[Fact]
Expand Down Expand Up @@ -320,7 +320,7 @@ public void CanListAllReferencesEvenCorruptedOnes()

Assert.Equal(expectedRefs, SortedRefs(repo, r => r.CanonicalName));

Assert.Equal(13, repo.Refs.Count());
Assert.Equal(14, repo.Refs.Count());
}
}

Expand Down Expand Up @@ -730,9 +730,9 @@ public void CanFilterReferencesWithAGlob()
{
using (var repo = new Repository(BareTestRepoPath))
{
Assert.Equal(12, repo.Refs.FromGlob("*").Count());
Assert.Equal(13, repo.Refs.FromGlob("*").Count());
Assert.Equal(5, repo.Refs.FromGlob("refs/heads/*").Count());
Assert.Equal(4, repo.Refs.FromGlob("refs/tags/*").Count());
Assert.Equal(5, repo.Refs.FromGlob("refs/tags/*").Count());
Assert.Equal(3, repo.Refs.FromGlob("*t?[pqrs]t*").Count());
Assert.Equal(0, repo.Refs.FromGlob("test").Count());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x��� D=SŖ ?�j �.�A��1v/&��&� �h����,i���੕Rr�z�H�葔Ӌw����|!
n-�[8ׇ�� /!8����G�����$
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
252846a95d7b031136d19f5a8a85ebed204cdbef
23 changes: 21 additions & 2 deletions LibGit2Sharp.Tests/TagFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace LibGit2Sharp.Tests
{
public class TagFixture : BaseFixture
{
private readonly string[] expectedTags = new[] { "e90810b", "lw", "point_to_blob", "test", };
private readonly string[] expectedTags = new[] { "e90810b", "lw", "point_to_blob", "tag_without_tagger", "test", };

private static readonly Signature signatureTim = new Signature("Tim Clem", "timothy.clem@gmail.com", TruncateSubSeconds(DateTimeOffset.UtcNow));
private static readonly Signature signatureNtk = new Signature("nulltoken", "emeric.fermas@gmail.com", Epoch.ToDateTimeOffset(1300557894, 60));
Expand Down Expand Up @@ -350,6 +350,25 @@ public void CanAddATagPointingToATree()
}
}

[Fact]
public void CanReadTagWithoutTagger()
{
// Not all tags have a tagger.
using (var repo = new Repository(BareTestRepoPath))
{
Tag tag = repo.Tags["tag_without_tagger"];

Assert.True(tag.IsAnnotated);
Assert.NotNull(tag.Target);
Assert.Null(tag.Annotation.Tagger);

Tree tree = repo.Lookup<Tree>("581f9824ecaf824221bd36edf5430f2739a7c4f5");
Assert.NotNull(tree);

Assert.Equal(tree.Id, tag.Target.Id);
}
}

[Fact]
public void CanAddATagPointingToABlob()
{
Expand Down Expand Up @@ -590,7 +609,7 @@ public void CanListTags()
{
Assert.Equal(expectedTags, SortedTags(repo.Tags, t => t.Name));

Assert.Equal(4, repo.Tags.Count());
Assert.Equal(5, repo.Tags.Count());
}
}

Expand Down
12 changes: 11 additions & 1 deletion LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2885,7 +2885,17 @@ public static string git_tag_name(GitObjectSafeHandle tag)

public static Signature git_tag_tagger(GitObjectSafeHandle tag)
{
return new Signature(NativeMethods.git_tag_tagger(tag));
IntPtr taggerHandle = NativeMethods.git_tag_tagger(tag);

// Not all tags have a tagger signature - we need to handle
// this case.
Signature tagger = null;
if (taggerHandle != IntPtr.Zero)
{
tagger = new Signature(NativeMethods.git_tag_tagger(tag));
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this use taggerHandle?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes... it should. I will push up this change shortly.

}

return tagger;
}

public static ObjectId git_tag_target_id(GitObjectSafeHandle tag)
Expand Down