Code

Fix tig show by replacing %(commit) with %(revargs) on first display
authorJonas Fonseca <fonseca@diku.dk>
Sun, 19 Sep 2010 15:09:41 +0000 (11:09 -0400)
committerJonas Fonseca <fonseca@diku.dk>
Sun, 19 Sep 2010 15:09:41 +0000 (11:09 -0400)
NEWS
tig.c

diff --git a/NEWS b/NEWS
index e06467576bf23cc0e6b67614a000eaac9d4b0700..583592df1aa39671c87d1cea3f8ffeb88055d66c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Improvements:
 
 Bug fixes:
 
+ - Fix 'tig show <commit>' 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 e0e812c605128f15d40c104d8ba1373c51ff3a0e..7bc5daaaeeb440018bcb7642e42af11c66ea63ad 100644 (file)
--- 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);