summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2291317)
raw | patch | inline | side by side (parent: 2291317)
author | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 1 Jun 2006 02:08:44 +0000 (04:08 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Thu, 1 Jun 2006 02:08:44 +0000 (04:08 +0200) |
tig.c | patch | blob | history |
index 4e1ffcb5c3a368412048c60f1b809e5bac8ccc5b..f541697a26a5863a829785e0c1454729941aa325 100644 (file)
--- a/tig.c
+++ b/tig.c
{
struct ref *ref;
bool tag = FALSE;
- bool tag_commit = FALSE;
- /* Commits referenced by tags has "^{}" appended. */
- if (name[namelen - 1] == '}') {
+ if (!strncmp(name, "refs/tags/", STRING_SIZE("refs/tags/"))) {
+ /* Commits referenced by tags has "^{}" appended. */
+ if (name[namelen - 1] != '}')
+ return OK;
+
while (namelen > 0 && name[namelen] != '^')
namelen--;
- if (namelen > 0)
- tag_commit = TRUE;
- name[namelen] = 0;
- }
- if (!strncmp(name, "refs/tags/", STRING_SIZE("refs/tags/"))) {
- if (!tag_commit)
- return OK;
- name += STRING_SIZE("refs/tags/");
tag = TRUE;
+ namelen -= STRING_SIZE("refs/tags/");
+ name += STRING_SIZE("refs/tags/");
} else if (!strncmp(name, "refs/heads/", STRING_SIZE("refs/heads/"))) {
- name += STRING_SIZE("refs/heads/");
+ namelen -= STRING_SIZE("refs/heads/");
+ name += STRING_SIZE("refs/heads/");
} else if (!strcmp(name, "HEAD")) {
return OK;
return ERR;
ref = &refs[refs_size++];
- ref->name = strdup(name);
+ ref->name = malloc(namelen + 1);
if (!ref->name)
return ERR;
+ strncpy(ref->name, name, namelen);
+ ref->name[namelen] = 0;
ref->tag = tag;
string_copy(ref->id, id);