From a7fff549aa5df2d23903308252da625b079b944f Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 9 Feb 2009 04:04:40 +0100 Subject: [PATCH] Status view: upon failure to open a file show error message --- NEWS | 1 + tig.c | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index ea3296c..f9b2e7f 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ Improvements: Bug fixes: + - Status view: show error when failing to open a file. - Blame view: fix problem with uninitialized variable. - Blame view: use line number information when loading blame for specific commit. diff --git a/tig.c b/tig.c index b09cbbf..aec50bc 100644 --- a/tig.c +++ b/tig.c @@ -398,6 +398,8 @@ io_open(struct io *io, const char *name) { init_io(io, NULL, IO_FD); io->pipe = *name ? open(name, O_RDONLY) : STDIN_FILENO; + if (io->pipe == -1) + io->error = errno; return io->pipe != -1; } @@ -4901,6 +4903,15 @@ status_draw(struct view *view, struct line *line, unsigned int lineno) return TRUE; } +static enum request +status_load_error(struct view *view, struct view *stage, const char *path) +{ + if (displayed_views() == 2 || display[current_view] != view) + maximize_view(view); + report("Failed to load '%s': %s", path, io_strerror(&stage->io)); + return REQ_NONE; +} + static enum request status_enter(struct view *view, struct line *line) { @@ -4928,7 +4939,7 @@ status_enter(struct view *view, struct line *line) }; if (!prepare_update(stage, no_head_diff_argv, opt_cdup, FORMAT_DASH)) - return REQ_QUIT; + return status_load_error(view, stage, newpath); } else { const char *index_show_argv[] = { "git", "diff-index", "--root", "--patch-with-stat", @@ -4937,7 +4948,7 @@ status_enter(struct view *view, struct line *line) }; if (!prepare_update(stage, index_show_argv, opt_cdup, FORMAT_DASH)) - return REQ_QUIT; + return status_load_error(view, stage, newpath); } if (status) @@ -4954,7 +4965,7 @@ status_enter(struct view *view, struct line *line) }; if (!prepare_update(stage, files_show_argv, opt_cdup, FORMAT_DASH)) - return REQ_QUIT; + return status_load_error(view, stage, newpath); if (status) info = "Unstaged changes to %s"; else @@ -4973,7 +4984,7 @@ status_enter(struct view *view, struct line *line) } if (!prepare_update_file(stage, newpath)) - return REQ_QUIT; + return status_load_error(view, stage, newpath); info = "Untracked file %s"; break; @@ -5232,8 +5243,7 @@ status_request(struct view *view, enum request request, struct line *line) /* After returning the status view has been split to * show the stage view. No further reloading is * necessary. */ - status_enter(view, line); - return REQ_NONE; + return status_enter(view, line); case REQ_REFRESH: /* Simply reload the view. */ -- 2.32.0.93.g670b81a890