From 918008baddc311e810c4bdc5fd548ee10fc83399 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sun, 28 Dec 2008 12:47:28 -0500 Subject: [PATCH] Use switch statement in tree_request --- tig.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tig.c b/tig.c index 6f25bec..8059202 100644 --- 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) -- 2.30.2