libgit2/libgit2 — pull request #2153 by mekishizufu (2014-03-04 00:03:30+00:00)
Title: Add a tag example

Hey guys!

As part of messing with the library I thought I'd try to recreate the `tag` command so here it goes. It supports the basic operations one would expect:

- Tag name listing (`tag`)
- Filtered tag listing with messages (`tag -n3 -l "v0.1*"`)
- Lightweight tag creation (`tag test v0.18.0`)
- Tag creation (`tag -a -m "Test message" test v0.18.0`)
- Tag deletion (`tag -d test`)

It works on my machine© but I would really appreciate it if you could give it a second look and report any issues (API usage or C in general).

Also a few non-blocking observations/questions:

- `git_tag_delete` (and also `git_reflog_delete`) takes `git_repository *` and `const char *name`. It doesn't seem to be consistent with e.g. `git_reference_delete` (that takes `git_reference *`) or with `git_branch_delete` (`git_reference *`). There's `git_reference_remove` for removing by name.

- While implementing the tag deletion, I needed to get the tag's abbrev and noticed there's `git_oid_shorten` for doing that. If I'm reading the API correctly, I need to fill up the shortener with all of the oids from the whole repository. Is that correct? It sounds expensive. Also something like `git_object_id_short(const git_object *obj)` would be nice.