index f562218376a5f17edc4722ce7e2fb25b4b985ec5..047b853b67396961cd12361489cb9a911843c140 100644 (file)
--- a/tig.c
+++ b/tig.c
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
-start_update(struct view *view, const char **argv, const char *dir)
-{
- return prepare_update(view, dir, argv) &&
- io_run(&view->io, IO_RD, dir, view->argv);
-}
-
static bool
begin_update(struct view *view, const char *dir, const char **argv, enum open_flags flags)
{
@@ -2784,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);
@@ -2794,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
return TRUE;
} else if (!text) {
- char *path = *opt_path ? opt_path : ".";
/* Find next entry to process */
const char *log_file[] = {
"git", "log", "--no-color", "--pretty=raw",
- "--cc", "--raw", view->id, "--", path, NULL
+ "--cc", "--raw", view->id, "--", "%(directory)", NULL
};
if (!view->lines) {
return TRUE;
}
- if (!start_update(view, log_file, opt_cdup)) {
+ if (!begin_update(view, opt_cdup, log_file, OPEN_EXTRA)) {
report("Failed to load tree data");
return TRUE;
}
"--simplify-by-decoration", "--all", NULL
};
- if (!start_update(view, branch_log, NULL)) {
+ if (!begin_update(view, NULL, branch_log, flags)) {
report("Failed to load branch data");
return TRUE;
}
- setup_update(view, view->id);
branch_open_visitor(view, &branch_all);
foreach_ref(branch_open_visitor, view);
view->p_restore = TRUE;