Code

Status view: upon failure to open a file show error message
authorJonas Fonseca <fonseca@diku.dk>
Mon, 9 Feb 2009 03:04:40 +0000 (04:04 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Mon, 9 Feb 2009 03:19:35 +0000 (04:19 +0100)
NEWS
tig.c

diff --git a/NEWS b/NEWS
index ea3296c79b29f8bb5ba34146811a1422aac3f674..f9b2e7f912328e2aa10846fba327226636416423 100644 (file)
--- 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 b09cbbfc513b89a9bd4701df8bed6a70eb615477..aec50bca39ff98d3d8358789c6a70f676e2d5bfb 100644 (file)
--- 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. */