Code

Minor cleanup of the tree view code; fix enter on the first line
authorJonas Fonseca <fonseca@diku.dk>
Tue, 27 Jan 2009 12:51:12 +0000 (13:51 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Tue, 27 Jan 2009 15:33:19 +0000 (16:33 +0100)
tig.c

diff --git a/tig.c b/tig.c
index 6bbe2920ffda6167c4e5388c4fbbc07eff45ee27..8c65a4753bb9d2809a7bc93b23d43eb562b8884b 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -3676,14 +3676,12 @@ push_tree_stack_entry(const char *name, unsigned long lineno)
 #define SIZEOF_TREE_ATTR \
        STRING_SIZE("100644 blob ed09fe897f3c7c9af90bcf80cae92558ea88ae38\t")
 
-#define SIZEOF_TREE_PERM \
+#define SIZEOF_TREE_MODE \
        STRING_SIZE("100644 ")
 
 #define TREE_ID_OFFSET \
        STRING_SIZE("100644 blob ")
 
-#define TREE_UP_FORMAT "040000 tree %s\t.."
-
 struct tree_entry {
        char id[SIZEOF_REV];
        mode_t mode;
@@ -3820,7 +3818,7 @@ tree_read(struct view *view, char *text)
        /* Strip the path part ... */
        if (*opt_path) {
                size_t pathlen = textlen - SIZEOF_TREE_ATTR;
-                size_t striplen = strlen(opt_path);
+               size_t striplen = strlen(opt_path);
 
                if (pathlen > striplen)
                        memmove(path, path + striplen,
@@ -3832,9 +3830,7 @@ tree_read(struct view *view, char *text)
                        return FALSE;
        }
 
-       type = text[STRING_SIZE("100644 ")] == 't'
-            ? LINE_TREE_DIR : LINE_TREE_FILE;
-
+       type = text[SIZEOF_TREE_MODE] == 't' ? LINE_TREE_DIR : LINE_TREE_FILE;
        entry = tree_entry(view, type, path, text, text + TREE_ID_OFFSET);
        if (!entry)
                return FALSE;
@@ -3988,13 +3984,12 @@ tree_request(struct view *view, enum request request, struct line *line)
                break;
 
        default:
-               return TRUE;
+               return REQ_NONE;
        }
 
        open_view(view, request, flags);
-       if (request == REQ_VIEW_TREE) {
+       if (request == REQ_VIEW_TREE)
                view->lineno = tree_lineno;
-       }
 
        return REQ_NONE;
 }