Code

Merge prepare_update into open_argv; make open_file call open_argv
authorJonas Fonseca <fonseca@diku.dk>
Sat, 9 Apr 2011 18:26:20 +0000 (14:26 -0400)
committerJonas Fonseca <fonseca@diku.dk>
Sat, 9 Apr 2011 18:26:20 +0000 (14:26 -0400)
tig.c

diff --git a/tig.c b/tig.c
index ac053b3510349b777f604a6bf13cb63d986387de..047b853b67396961cd12361489cb9a911843c140 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2500,15 +2500,6 @@ setup_update(struct view *view, const char *vid)
        view->start_time = time(NULL);
 }
 
-static bool
-prepare_update(struct view *view, const char *dir, const char *argv[])
-{
-       if (view->pipe)
-               io_done(view->pipe);
-       view->dir = dir;
-       return argv_copy(&view->argv, argv);
-}
-
 static bool
 begin_update(struct view *view, const char *dir, const char **argv, enum open_flags flags)
 {
@@ -2777,7 +2768,11 @@ open_argv(struct view *prev, struct view *view, const char *argv[], const char *
 {
        enum request request = view - views + REQ_OFFSET + 1;
 
-       if (!prepare_update(view, dir, argv)) {
+       if (view->pipe)
+               end_update(view, TRUE);
+       view->dir = dir;
+       
+       if (!argv_copy(&view->argv, argv)) {
                report("Failed to open %s view: %s", view->name, io_strerror(&view->io));
        } else {
                open_view(prev, request, flags | OPEN_PREPARED);
@@ -2787,17 +2782,9 @@ open_argv(struct view *prev, struct view *view, const char *argv[], const char *
 static void
 open_file(struct view *prev, struct view *view, const char *file, enum open_flags flags)
 {
-       enum request request = view - views + REQ_OFFSET + 1;
        const char *file_argv[] = { opt_cdup, file , NULL };
 
-       if (view->pipe)
-               end_update(view, TRUE);
-       view->dir = opt_cdup;
-       if (!argv_copy(&view->argv, file_argv)) {
-               report("Failed to load %s: out of memory", file);
-       } else {
-               open_view(prev, request, flags | OPEN_PREPARED);
-       }
+       open_argv(prev, view, file_argv, opt_cdup, flags); 
 }
 
 static void