From cae23453bf77ee4b9d037061b13d4f1c094700e1 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Wed, 10 Sep 2008 15:46:51 +0200 Subject: [PATCH] main: implement refreshing by just rerunning the original command Also updates NEWS to mention the fix from last commit. --- NEWS | 3 +++ tig.c | 29 ++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index d93fb04..9ebcbea 100644 --- 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 8362ecf..fd0076f 100644 --- 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; } -- 2.30.2