Code

Branch view: fix loading to handle when two branches have same commit
authorJonas Fonseca <fonseca@diku.dk>
Sat, 21 Feb 2009 00:15:05 +0000 (01:15 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Sat, 21 Feb 2009 00:16:20 +0000 (01:16 +0100)
tig.c

diff --git a/tig.c b/tig.c
index 9349f697f5b72b7b112ba6c6e28296862ea77f95..13d1c45038042edbd391230f9f0b53b69cae65fd 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -4646,7 +4646,7 @@ branch_draw(struct view *view, struct line *line, unsigned int lineno)
        struct branch *branch = line->data;
        enum line_type type = branch->ref->head ? LINE_MAIN_HEAD : LINE_DEFAULT;
 
-       if (opt_date && draw_date(view, &branch->time))
+       if (opt_date && draw_date(view, branch->author ? &branch->time : NULL))
                return TRUE;
 
        if (opt_author && draw_author(view, branch->author))
@@ -4678,6 +4678,7 @@ static bool
 branch_read(struct view *view, char *line)
 {
        static char id[SIZEOF_REV];
+       struct branch *reference;
        size_t i;
 
        if (!line)
@@ -4689,15 +4690,22 @@ branch_read(struct view *view, char *line)
                return TRUE;
 
        case LINE_AUTHOR:
-               for (i = 0; i < view->lines; i++) {
+               for (i = 0, reference = NULL; i < view->lines; i++) {
                        struct branch *branch = view->line[i].data;
 
                        if (strcmp(branch->ref->id, id))
                                continue;
 
+                       view->line[i].dirty = TRUE;
+                       if (reference) {
+                               branch->author = reference->author;
+                               branch->time = reference->time;
+                               continue;
+                       }
+
                        parse_author_line(line + STRING_SIZE("author "),
                                          &branch->author, &branch->time);
-                       view->line[i].dirty = TRUE;
+                       reference = branch;
                }
                return TRUE;