From 80e97cdd456dfe71d0dbf32d77a73bb5a2ab158e Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sun, 19 Sep 2010 11:09:41 -0400 Subject: [PATCH] Fix tig show by replacing %(commit) with %(revargs) on first display Broken in commit 53c089443cd9885fa677becee4bf7ffd56c3c357. --- NEWS | 1 + tig.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index e064675..583592d 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ Improvements: Bug fixes: + - Fix 'tig show ' to show the provided commit. - Fix problem with empty diff views when file specs were passed on the command line. - Fix segfault when starting tig in pager mode. diff --git a/tig.c b/tig.c index e0e812c..7bc5daa 100644 --- a/tig.c +++ b/tig.c @@ -3224,7 +3224,7 @@ format_arg(const char *name) } static bool -format_argv(const char ***dst_argv, const char *src_argv[], bool replace) +format_argv(const char ***dst_argv, const char *src_argv[], bool replace, bool first) { char buf[SIZEOF_STR]; int argc; @@ -3245,7 +3245,8 @@ format_argv(const char ***dst_argv, const char *src_argv[], bool replace) break; continue; - } else if (!strcmp(arg, "%(revargs)")) { + } else if (!strcmp(arg, "%(revargs)") || + (first && !strcmp(arg, "%(commit)"))) { if (!argv_append_array(dst_argv, opt_rev_args)) break; continue; @@ -3331,7 +3332,7 @@ static bool prepare_io(struct view *view, const char *dir, const char *argv[], bool replace) { view->dir = dir; - return format_argv(&view->argv, argv, replace); + return format_argv(&view->argv, argv, replace, !view->parent); } static bool @@ -3668,7 +3669,7 @@ open_run_request(enum request request) return; } - if (format_argv(&argv, req->argv, TRUE)) + if (format_argv(&argv, req->argv, TRUE, FALSE)) open_external_viewer(argv, NULL); if (argv) argv_free(argv); -- 2.30.2