From 04b1febd46b3edf2c47ad5d39d6b974bda7ec071 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 22 Jun 2010 22:52:58 -0400 Subject: [PATCH] Fall back to retry if no diff will be shown This can happen if a file spec was passed on the command line and the diff view is opened from the blame view with a different path. --- NEWS | 8 ++++++++ tig.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index af9312d..41729f7 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,14 @@ Release notes ============= +tig master +---------- + +Bug fixes: + + - Fix problem with empty diff views when file specs were passed on the + command line. + tig-0.16 -------- diff --git a/tig.c b/tig.c index e2e83ff..5f4c263 100644 --- a/tig.c +++ b/tig.c @@ -4194,11 +4194,38 @@ static const char *diff_argv[SIZEOF_ARG] = { "%(diffargs)", "%(commit)", "--", "%(fileargs)", NULL }; +static bool +diff_read(struct view *view, char *data) +{ + if (!data) { + /* Fall back to retry if no diff will be shown. */ + if (view->lines == 0 && opt_file_args) { + int pos = argv_size(view->argv) + - argv_size(opt_file_args) - 1; + + if (pos > 0 && !strcmp(view->argv[pos], "--")) { + for (; view->argv[pos]; pos++) { + free((void *) view->argv[pos]); + view->argv[pos] = NULL; + } + + if (view->pipe) + io_done(view->pipe); + if (io_run(&view->io, IO_RD, view->dir, view->argv)) + return FALSE; + } + } + return TRUE; + } + + return pager_read(view, data); +} + static struct view_ops diff_ops = { "line", diff_argv, NULL, - pager_read, + diff_read, pager_draw, pager_request, pager_grep, -- 2.30.2