X-Git-Url: https://git.distorted.org.uk/~mdw/tig/blobdiff_plain/2b42e5d686833a9f45020dfeb8148832d0ad30f7..4795d620f98daae0f972ff61341991656af9c88b:/tig.c diff --git a/tig.c b/tig.c index 384fe21..a871cb0 100644 --- a/tig.c +++ b/tig.c @@ -565,6 +565,7 @@ LINE(TREE, "tree ", COLOR_BLUE, COLOR_DEFAULT, 0), \ LINE(AUTHOR, "author ", COLOR_CYAN, COLOR_DEFAULT, 0), \ LINE(COMMITTER, "committer ", COLOR_MAGENTA, COLOR_DEFAULT, 0), \ LINE(SIGNOFF, " Signed-off-by", COLOR_YELLOW, COLOR_DEFAULT, 0), \ +LINE(ACKED, " Acked-by", COLOR_YELLOW, COLOR_DEFAULT, 0), \ LINE(DEFAULT, "", COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), \ LINE(CURSOR, "", COLOR_WHITE, COLOR_GREEN, A_BOLD), \ LINE(STATUS, "", COLOR_GREEN, COLOR_DEFAULT, 0), \ @@ -1523,7 +1524,7 @@ scroll_view(struct view *view, enum request request) static void move_view(struct view *view, enum request request) { - bool scroll = FALSE; + int scroll_steps = 0; int steps; switch (request) { @@ -1573,19 +1574,18 @@ move_view(struct view *view, enum request request) /* Check whether the view needs to be scrolled */ if (view->lineno < view->offset || view->lineno >= view->offset + view->height) { + scroll_steps = steps; if (steps < 0 && -steps > view->offset) { - steps = -view->offset; + scroll_steps = -view->offset; } else if (steps > 0) { if (view->lineno == view->lines - 1 && view->lines > view->height) { - steps = view->lines - view->offset - 1; - if (steps >= view->height) - steps -= view->height - 1; + scroll_steps = view->lines - view->offset - 1; + if (scroll_steps >= view->height) + scroll_steps -= view->height - 1; } } - - scroll = TRUE; } if (!view_is_displayed(view)) { @@ -1598,8 +1598,8 @@ move_view(struct view *view, enum request request) if (ABS(steps) < view->height) draw_view_line(view, view->lineno - steps - view->offset); - if (scroll) { - do_scroll_view(view, steps); + if (scroll_steps) { + do_scroll_view(view, scroll_steps); return; } @@ -2447,7 +2447,7 @@ static struct view_ops pager_ops = { * Tree backend */ -/* Parse output from git ls-tree: +/* Parse output from git-ls-tree(1): * * 100644 blob fb0e31ea6cc679b7379631188190e975f5789c26 Makefile * 100644 blob 5304ca4260aaddaee6498f9630e7d471b8591ea6 README @@ -2558,7 +2558,6 @@ static bool tree_enter(struct view *view, struct line *line) { enum open_flags flags = display[0] == view ? OPEN_SPLIT : OPEN_DEFAULT; - char *data = line->data; enum request request; switch (line->type) { @@ -2577,6 +2576,7 @@ tree_enter(struct view *view, struct line *line) } else { size_t pathlen = strlen(opt_path); size_t origlen = pathlen; + char *data = line->data; char *basename = data + SIZEOF_TREE_ATTR; if (!string_format_from(opt_path, &pathlen, "%s/", basename)) { @@ -2601,29 +2601,27 @@ tree_enter(struct view *view, struct line *line) open_view(view, request, flags); - if (!VIEW(request)->pipe) - return TRUE; - - /* For tree views insert the path to the parent as the first line. */ - if (request == REQ_VIEW_BLOB) { - /* Mirror what is showed in the title bar. */ - string_ncopy(ref_blob, data + STRING_SIZE("100644 blob "), 40); - string_copy(VIEW(REQ_VIEW_BLOB)->ref, ref_blob); - return TRUE; - } - return TRUE; } static void tree_select(struct view *view, struct line *line) { - if (line->type == LINE_TREE_DIR || line->type == LINE_TREE_FILE) { - char *text = line->data; + char *text = line->data; - string_ncopy(view->ref, text + STRING_SIZE("100644 blob "), 40); - string_copy(ref_blob, view->ref); + text += STRING_SIZE("100644 blob "); + + if (line->type == LINE_TREE_FILE) { + string_ncopy(ref_blob, text, 40); + /* Also update the blob view's ref, since all there must always + * be in sync. */ + string_copy(VIEW(REQ_VIEW_BLOB)->ref, ref_blob); + + } else if (line->type != LINE_TREE_DIR) { + return; } + + string_ncopy(view->ref, text, 40); } static struct view_ops tree_ops = {