summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 58cc60c)
raw | patch | inline | side by side (parent: 58cc60c)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 11 Jan 2009 22:15:00 +0000 (23:15 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 13 Jan 2009 21:55:19 +0000 (22:55 +0100) |
tig.c | patch | blob | history |
index 375f1bd71b9aab1bfdf57cb9339e0483cb2b06a4..1fe9afb734ca9174498533cb55c551177a71d1c0 100644 (file)
--- a/tig.c
+++ b/tig.c
char buf[SIZEOF_STR * 2];
size_t bufpos = 0;
+ if (io->type == IO_FD)
+ return TRUE;
+
if (io->dir && *io->dir &&
!string_format_from(buf, &bufpos, "cd %s;", io->dir))
return FALSE;
static char opt_head[SIZEOF_REF] = "";
static char opt_head_rev[SIZEOF_REV] = "";
static char opt_remote[SIZEOF_REF] = "";
-static FILE *opt_pipe = NULL;
static char opt_encoding[20] = "UTF-8";
static bool opt_utf8 = TRUE;
static char opt_codeset[20] = "UTF-8";
};
int i, j = 6;
- if (!isatty(STDIN_FILENO)) {
- opt_pipe = stdin;
+ if (!isatty(STDIN_FILENO))
return REQ_VIEW_PAGER;
- }
if (argc <= 1)
return REQ_VIEW_MAIN;
}
static bool
-begin_update(struct view *view, bool refresh)
+prepare_update_file(struct view *view, const char *name)
{
- if (init_io_fd(&view->io, opt_pipe)) {
- opt_pipe = NULL;
+ if (view->pipe)
+ end_update(view, TRUE);
+ return init_io_fd(&view->io, fopen(name, "r"));
+}
- } else if (refresh) {
+static bool
+begin_update(struct view *view, bool refresh)
+{
+ if (refresh) {
if (!start_io(&view->io))
return FALSE;
break;
case REQ_VIEW_PAGER:
- if (!opt_pipe && !VIEW(REQ_VIEW_PAGER)->lines) {
+ if (!VIEW(REQ_VIEW_PAGER)->pipe && !VIEW(REQ_VIEW_PAGER)->lines) {
report("No pager content, press %s to run command from prompt",
get_key(REQ_PROMPT));
break;
break;
}
case LINE_STAT_UNTRACKED:
- if (opt_pipe)
- return REQ_QUIT;
-
if (!newpath) {
report("No file to show");
return REQ_NONE;
return REQ_NONE;
}
- opt_pipe = fopen(status->new.name, "r");
+ if (!prepare_update_file(stage, newpath))
+ return REQ_QUIT;
info = "Untracked file %s";
break;
return REQ_NONE;
}
- opt_pipe = fopen(stage_status.new.name, "r");
+ 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);
init_display();
- if (run_argv) {
- if (!prepare_update(VIEW(request), run_argv, NULL, FORMAT_NONE))
+ if (request == REQ_VIEW_PAGER || run_argv) {
+ if (request == REQ_VIEW_PAGER)
+ init_io_fd(&VIEW(request)->io, stdin);
+ else if (!prepare_update(VIEW(request), run_argv, NULL, FORMAT_NONE))
die("Failed to format arguments");
- open_view(display[current_view], request, OPEN_PREPARED);
+ open_view(NULL, request, OPEN_PREPARED);
request = REQ_NONE;
}