From: Jonas Fonseca Date: Fri, 11 Mar 2011 03:44:54 +0000 (-0500) Subject: Enhance prepare_update_file to add support for refreshable file IO X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7dfa0b29496911af61a3d761979db0b1093fec6a;p=tig.git Enhance prepare_update_file to add support for refreshable file IO --- diff --git a/io.c b/io.c index edd6e85..fabde00 100644 --- a/io.c +++ b/io.c @@ -97,6 +97,7 @@ argv_copy(const char ***dst, const char *src[]) { int argc; + argv_free(*dst); for (argc = 0; src[argc]; argc++) if (!argv_append(dst, src[argc])) return FALSE; diff --git a/tig.c b/tig.c index 1d3122d..8b46fa7 100644 --- a/tig.c +++ b/tig.c @@ -2524,10 +2524,11 @@ start_update(struct view *view, const char **argv, const char *dir) static bool prepare_update_file(struct view *view, const char *name) { + const char *file_argv[] = { opt_cdup, name , NULL }; + if (view->pipe) end_update(view, TRUE); - argv_free(view->argv); - return io_open(&view->io, "%s/%s", opt_cdup[0] ? opt_cdup : ".", name); + return argv_copy(&view->argv, file_argv); } static bool @@ -2556,6 +2557,9 @@ 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); @@ -5687,17 +5691,6 @@ stage_request(struct view *view, enum request request, struct line *line) return REQ_VIEW_CLOSE; } - if (stage_line_type == LINE_STAT_UNTRACKED) { - if (!suffixcmp(stage_status.new.name, -1, "/")) { - report("Cannot display a directory"); - return REQ_NONE; - } - - if (!prepare_update_file(view, stage_status.new.name)) { - report("Failed to open file: %s", strerror(errno)); - return REQ_NONE; - } - } open_view(view, REQ_VIEW_STAGE, OPEN_REFRESH); return REQ_NONE;