Code

main: implement refreshing by just rerunning the original command
authorJonas Fonseca <fonseca@diku.dk>
Wed, 10 Sep 2008 13:46:51 +0000 (15:46 +0200)
committerJonas Fonseca <fonseca@diku.dk>
Wed, 10 Sep 2008 13:53:56 +0000 (15:53 +0200)
Also updates NEWS to mention the fix from last commit.

NEWS
tig.c

diff --git a/NEWS b/NEWS
index d93fb04bc7cb317e03ad2a8b7febe567ba850a96..9ebcbeabc7c8c55fde9450efaf961e515d8fb0d5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Improvements:
  - F5 also refreshes the current view.
  - Allow line graphics to be disabled with new line-graphics option.
  - Main view: also include the reference names when searching.
+ - Main view: support for refreshing.
  - Stage view: add stage-next action to jump to next diff chunk that can
    be staged. By default bound to '@'.
  - Configure: check for the ncurses header files.
@@ -24,6 +25,8 @@ Bug fixes:
    installed as /bin/sh does not support it.
  - Do not show incomplete boundary commits when --no-walk is used.
  - Documentation: Rename gitlink macro to support AsciiDoc 8.2.3.
+ - Ignore pipe reads with errno "Success" reported after a signals,
+   for example when refreshing doing background loading.
 
 tig-0.11
 --------
diff --git a/tig.c b/tig.c
index 8362ecf39b13c2cbc62b98cde24165e8cfb52fe3..fd0076f076e38b2e3f2a6374a376e84f27046f42 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -4760,6 +4760,15 @@ append_to_rev_graph(struct rev_graph *graph, chtype symbol)
                commit->graph[commit->graph_size++] = symbol;
 }
 
+static void
+clear_rev_graph(struct rev_graph *graph)
+{
+       graph->boundary = 0;
+       graph->size = graph->pos = 0;
+       graph->commit = NULL;
+       memset(graph->parents, 0, sizeof(*graph->parents));
+}
+
 static void
 done_rev_graph(struct rev_graph *graph)
 {
@@ -4776,9 +4785,7 @@ done_rev_graph(struct rev_graph *graph)
                }
        }
 
-       graph->size = graph->pos = 0;
-       graph->commit = NULL;
-       memset(graph->parents, 0, sizeof(*graph->parents));
+       clear_rev_graph(graph);
 }
 
 static void
@@ -4981,6 +4988,8 @@ main_read(struct view *view, char *line)
        struct commit *commit;
 
        if (!line) {
+               int i;
+
                if (!view->lines && !view->parent)
                        die("No revisions match the given arguments.");
                if (view->lines > 0) {
@@ -4992,6 +5001,9 @@ main_read(struct view *view, char *line)
                        }
                }
                update_rev_graph(graph);
+
+               for (i = 0; i < ARRAY_SIZE(graph_stacks); i++)
+                       clear_rev_graph(&graph_stacks[i]);
                return TRUE;
        }
 
@@ -5111,10 +5123,17 @@ main_request(struct view *view, enum request request, struct line *line)
 {
        enum open_flags flags = display[0] == view ? OPEN_SPLIT : OPEN_DEFAULT;
 
-       if (request == REQ_ENTER)
+       switch (request) {
+       case REQ_ENTER:
                open_view(view, REQ_VIEW_DIFF, flags);
-       else
+               break;
+       case REQ_REFRESH:
+               string_copy(opt_cmd, view->cmd);
+               open_view(view, REQ_VIEW_MAIN, OPEN_RELOAD);
+               break;
+       default:
                return request;
+       }
 
        return REQ_NONE;
 }