Code

Fix file mode diff header handling; fix repo refs
authorJonas Fonseca <fonseca@diku.dk>
Sun, 14 May 2006 06:23:01 +0000 (08:23 +0200)
committerJonas Fonseca <fonseca@antimatter.localdomain>
Sun, 14 May 2006 06:23:01 +0000 (08:23 +0200)
tig.c

diff --git a/tig.c b/tig.c
index 20abf8015c78da5212da3ed0b9338e2047e6ab56..d525251bf1215547d76f6c4ada0b39ccaf74b0c2 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -497,8 +497,8 @@ LINE(DIFF_INDEX,   "index ",                COLOR_BLUE,     COLOR_DEFAULT,  0), \
 LINE(DIFF_CHUNK,   "@@",               COLOR_MAGENTA,  COLOR_DEFAULT,  0), \
 LINE(DIFF_ADD,    "+",                 COLOR_GREEN,    COLOR_DEFAULT,  0), \
 LINE(DIFF_DEL,    "-",                 COLOR_RED,      COLOR_DEFAULT,  0), \
-LINE(DIFF_OLDMODE, "old mode ",                COLOR_YELLOW,   COLOR_DEFAULT,  0), \
-LINE(DIFF_NEWMODE, "new mode ",                COLOR_YELLOW,   COLOR_DEFAULT,  0), \
+LINE(DIFF_OLDMODE, "old file mode ",   COLOR_YELLOW,   COLOR_DEFAULT,  0), \
+LINE(DIFF_NEWMODE, "new file mode ",   COLOR_YELLOW,   COLOR_DEFAULT,  0), \
 LINE(DIFF_COPY,           "copy ",             COLOR_YELLOW,   COLOR_DEFAULT,  0), \
 LINE(DIFF_RENAME,  "rename ",          COLOR_YELLOW,   COLOR_DEFAULT,  0), \
 LINE(DIFF_SIM,    "similarity ",       COLOR_YELLOW,   COLOR_DEFAULT,  0), \
@@ -1771,9 +1771,15 @@ get_refs(char *id)
                }
 
                id_refs = tmp;
-               id_refs[id_refs_size++] = &refs[i];
-               if (id_refs_size > 1)
+               if (id_refs_size > 0)
                        id_refs[id_refs_size - 1]->next = 1;
+               id_refs[id_refs_size] = &refs[i];
+
+               /* XXX: The properties of the commit chains ensures that we can
+                * safely modify the shared ref. The repo references will
+                * always be similar for the same id. */
+               id_refs[id_refs_size]->next = 0;
+               id_refs_size++;
        }
 
        return id_refs;
@@ -1811,6 +1817,12 @@ load_refs(void)
                if (!strncmp(name, "refs/tags/", STRING_SIZE("refs/tags/"))) {
                        name += STRING_SIZE("refs/tags/");
                        tag = TRUE;
+
+               } else if (!strncmp(name, "refs/heads/", STRING_SIZE("refs/heads/"))) {
+                       name += STRING_SIZE("refs/heads/");
+
+               } else if (!strcmp(name, "HEAD")) {
+                       continue;
                }
 
                refs = realloc(refs, sizeof(*refs) * (refs_size + 1));