chiark
/
gitweb
/
~mdw
/
tig
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2291317
)
Simplify detection of tag commits via ^{}
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
|
blame
|
history
diff --git
a/tig.c
b/tig.c
index 4e1ffcb5c3a368412048c60f1b809e5bac8ccc5b..f541697a26a5863a829785e0c1454729941aa325 100644
(file)
--- a/
tig.c
+++ b/
tig.c
@@
-2420,25
+2420,22
@@
read_ref(char *id, int idlen, char *name, int namelen)
{
struct ref *ref;
bool tag = FALSE;
{
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--;
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;
tag = TRUE;
+ namelen -= STRING_SIZE("refs/tags/");
+ name += STRING_SIZE("refs/tags/");
} else if (!strncmp(name, "refs/heads/", STRING_SIZE("refs/heads/"))) {
} 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;
} else if (!strcmp(name, "HEAD")) {
return OK;
@@
-2449,10
+2446,12
@@
read_ref(char *id, int idlen, char *name, int namelen)
return ERR;
ref = &refs[refs_size++];
return ERR;
ref = &refs[refs_size++];
- ref->name =
strdup(name
);
+ ref->name =
malloc(namelen + 1
);
if (!ref->name)
return ERR;
if (!ref->name)
return ERR;
+ strncpy(ref->name, name, namelen);
+ ref->name[namelen] = 0;
ref->tag = tag;
string_copy(ref->id, id);
ref->tag = tag;
string_copy(ref->id, id);