Code

Use switch statement in tree_request
authorJonas Fonseca <fonseca@diku.dk>
Sun, 28 Dec 2008 17:47:28 +0000 (12:47 -0500)
committerJonas Fonseca <fonseca@diku.dk>
Sun, 28 Dec 2008 19:58:20 +0000 (14:58 -0500)
tig.c

diff --git a/tig.c b/tig.c
index 6f25bec53f3435f7c6fb82068edd00ec318a64cd..8059202b919e31b85e4aca248f8065bca4d604f6 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -3362,30 +3362,32 @@ tree_request(struct view *view, enum request request, struct line *line)
 {
        enum open_flags flags;
 
-       if (request == REQ_VIEW_BLAME) {
-               const char *filename = tree_path(line);
-
+       switch (request) {
+       case REQ_VIEW_BLAME:
                if (line->type != LINE_TREE_FILE) {
                        report("Blame only supported for files");
                        return REQ_NONE;
                }
 
                string_copy(opt_ref, view->vid);
-               string_format(opt_file, "%s%s", opt_path, filename);
+               string_format(opt_file, "%s%s", opt_path, tree_path(line));
                return request;
-       }
-       if (request == REQ_TREE_PARENT) {
-               if (*opt_path) {
-                       /* fake 'cd  ..' */
-                       request = REQ_ENTER;
-                       line = &view->line[1];
-               } else {
+
+       case REQ_TREE_PARENT:
+               if (!*opt_path) {
                        /* quit view if at top of tree */
                        return REQ_VIEW_CLOSE;
                }
-       }
-       if (request != REQ_ENTER)
+               /* fake 'cd  ..' */
+               line = &view->line[1];
+               break;
+
+       case REQ_ENTER:
+               break;
+
+       default:
                return request;
+       }
 
        /* Cleanup the stack if the tree view is at a different tree. */
        while (!*opt_path && tree_stack)