Code

Make the branch view always prepare how the main view is loaded
[tig.git] / tig.c
diff --git a/tig.c b/tig.c
index c27375311ff13b661715f99171a793c4bc945ca5..3e4d369063259d67589aabae0c8a8a47d871148a 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1703,7 +1703,7 @@ static size_t run_requests;
 DEFINE_ALLOCATOR(realloc_run_requests, struct run_request, 8)
 
 static enum request
-add_run_request(enum keymap keymap, int key, int argc, const char **argv)
+add_run_request(enum keymap keymap, int key, const char **argv)
 {
        struct run_request *req;
 
@@ -1736,16 +1736,11 @@ add_builtin_run_requests(void)
        const char *checkout[] = { "git", "checkout", "%(branch)", NULL };
        const char *commit[] = { "git", "commit", NULL };
        const char *gc[] = { "git", "gc", NULL };
-       struct {
-               enum keymap keymap;
-               int key;
-               int argc;
-               const char **argv;
-       } reqs[] = {
-               { KEYMAP_MAIN,    'C', ARRAY_SIZE(cherry_pick) - 1, cherry_pick },
-               { KEYMAP_STATUS,  'C', ARRAY_SIZE(commit) - 1, commit },
-               { KEYMAP_BRANCH,  'C', ARRAY_SIZE(checkout) - 1, checkout },
-               { KEYMAP_GENERIC, 'G', ARRAY_SIZE(gc) - 1, gc },
+       struct run_request reqs[] = {
+               { KEYMAP_MAIN,    'C', cherry_pick },
+               { KEYMAP_STATUS,  'C', commit },
+               { KEYMAP_BRANCH,  'C', checkout },
+               { KEYMAP_GENERIC, 'G', gc },
        };
        int i;
 
@@ -1754,7 +1749,7 @@ add_builtin_run_requests(void)
 
                if (req != reqs[i].key)
                        continue;
-               req = add_run_request(reqs[i].keymap, reqs[i].key, reqs[i].argc, reqs[i].argv);
+               req = add_run_request(reqs[i].keymap, reqs[i].key, reqs[i].argv);
                if (req != REQ_NONE)
                        add_keybinding(reqs[i].keymap, req, reqs[i].key);
        }
@@ -2027,7 +2022,7 @@ option_bind_command(int argc, const char *argv[])
                }
        }
        if (request == REQ_UNKNOWN && *argv[2]++ == '!')
-               request = add_run_request(keymap, key, argc - 2, argv + 2);
+               request = add_run_request(keymap, key, argv + 2);
        if (request == REQ_UNKNOWN) {
                config_msg = "Unknown request name";
                return ERR;
@@ -5340,23 +5335,21 @@ branch_request(struct view *view, enum request request, struct line *line)
                return REQ_NONE;
 
        case REQ_ENTER:
-               if (branch->ref == &branch_all) {
-                       const char *all_branches_argv[] = {
-                               "git", "log", "--no-color", "--pretty=raw", "--parents",
-                                     "--topo-order", "--all", NULL
-                       };
-                       struct view *main_view = VIEW(REQ_VIEW_MAIN);
+       {
+               const struct ref *ref = branch->ref;
+               const char *all_branches_argv[] = {
+                       "git", "log", "--no-color", "--pretty=raw", "--parents",
+                             "--topo-order",
+                             ref == &branch_all ? "--all" : ref->name, NULL
+               };
+               struct view *main_view = VIEW(REQ_VIEW_MAIN);
 
-                       if (!prepare_update(main_view, all_branches_argv, NULL)) {
-                               report("Failed to load view of all branches");
-                               return REQ_NONE;
-                       }
+               if (!prepare_update(main_view, all_branches_argv, NULL))
+                       report("Failed to load view of all branches");
+               else
                        open_view(view, REQ_VIEW_MAIN, OPEN_PREPARED | OPEN_SPLIT);
-               } else {
-                       open_view(view, REQ_VIEW_MAIN, OPEN_SPLIT);
-               }
                return REQ_NONE;
-
+       }
        default:
                return request;
        }