Code

io_run: make it possible to open file
authorJonas Fonseca <fonseca@diku.dk>
Sat, 9 Apr 2011 18:13:58 +0000 (14:13 -0400)
committerJonas Fonseca <fonseca@diku.dk>
Sat, 9 Apr 2011 18:13:58 +0000 (14:13 -0400)
io.c
tig.c

diff --git a/io.c b/io.c
index fabde00747eb5130e4b33c0dbe744ed05bc64977..901a3817065e32a46d623363b82be529840945a2 100644 (file)
--- a/io.c
+++ b/io.c
@@ -183,6 +183,9 @@ io_run(struct io *io, enum io_type type, const char *dir, const char *argv[], ..
 
        io_init(io);
 
+       if (dir && !strcmp(dir, argv[0]))
+               return io_open(io, "%s%s", dir, argv[1]);
+
        if ((type == IO_RD || type == IO_WR) && pipe(pipefds) < 0) {
                io->error = errno;
                return FALSE;
diff --git a/tig.c b/tig.c
index 7ad7fe741ce2b80ac74c58503b9529ed76ecb886..3ae55f23d78d87b0f2ad3bcec9d9f8591862913f 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2542,9 +2542,6 @@ begin_update(struct view *view, const char *dir, const char **argv, enum open_fl
        if (view->argv && view->argv[0] &&
            !io_run(&view->io, IO_RD, view->dir, view->argv))
                return FALSE;
-       else if (view->argv && !strcmp(view->argv[0], opt_cdup) &&
-                !io_open(&view->io, "%s%s", opt_cdup, view->argv[1]))
-               return FALSE;
 
        setup_update(view, view->id);
 
@@ -2795,6 +2792,7 @@ open_file(struct view *prev, struct view *view, const char *file, enum open_flag
 
        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 {