Skip to content
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

Tags are recognized as commits #6

Closed
gorbach opened this issue Apr 12, 2011 · 8 comments
Closed

Tags are recognized as commits #6

gorbach opened this issue Apr 12, 2011 · 8 comments
Assignees

Comments

@gorbach
Copy link
Contributor

gorbach commented Apr 12, 2011

Hi! I've found a strange issue. Enumerating tag in repository git://github.com/spdr870/gitextensions.git gives 81 nulls and 1 real tag. All other tags are visible in repo.Refs as commits.

Code to list tags:

        const string path = @"x:/git/ge/.git";
        using (var repo = new Repository(path))
        {
            int found = 0;
            foreach (var tag in repo.Tags.Where(t => t != null))
            {
                Console.WriteLine(tag.Name);
                found++;
            }

            Console.WriteLine("Found {0} of {1} tags.",found, repo.Tags.Count());

        }

sample code is available here - git@github.com:gorbach/libgit2sharp.git (branch git-log)

@ghost ghost assigned tclem Apr 12, 2011
@tclem
Copy link
Member

tclem commented Apr 12, 2011

Hmm... That is strange. I'll take a look!

@tclem
Copy link
Member

tclem commented Apr 12, 2011

Ok. So we aren't quite handling tag listing properly right now. I need to actually lookup the tag using the reference instead of just looking at what that reference points too (which is obviously a commit in most cases). It also looks like tag listing is actually getting support in libgit2 soon based on this PR.

@nulltoken
Copy link
Member

I think I nailed the root cause.

Git handles two different kinds of tags (annotated and lightweight).

  • Lightweight tags are nothing more than a direct reference to an object (commit, tree, ...)
  • Annotated tags are a combination of a tag-object stored in the git object database and a direct reference to this tag-object

@gorbach :

Currently, the "null" tags that you encounter are Lightweight tags.
Thanks for spotting this. It's a very nice issue :) We're working on it! Fixing this will require some slights changes to the API.

@gorbach
Copy link
Contributor Author

gorbach commented Apr 13, 2011

Yes, you right. This issue is caused by lightweight tags.

@ghost ghost assigned nulltoken Apr 14, 2011
@nulltoken
Copy link
Member

We've added support for lightweight tags.

Would you please check that nulltoken/libgit2sharp@1b73c29 indeed fixes the issue?

@gorbach
Copy link
Contributor Author

gorbach commented Apr 14, 2011

Thanks! Merged your fix, works very well. Waiting for merge in main branch.

@nulltoken
Copy link
Member

Quite glad it works as expected :)

Should be merged by tomorrow.

@nulltoken
Copy link
Member

This fix has been merged to libgit2/master. Thanks for having pointed this issue out :)

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

No branches or pull requests

3 participants