Code

Minor simplification of blame_open
authorJonas Fonseca <fonseca@diku.dk>
Wed, 31 Dec 2008 18:11:58 +0000 (13:11 -0500)
committerJonas Fonseca <fonseca@diku.dk>
Wed, 31 Dec 2008 18:46:38 +0000 (13:46 -0500)
tig.c

diff --git a/tig.c b/tig.c
index fe57bf4c6bb751dc4c5cb01204127781046819be..bcbc5fa027907a78e87946c558442595774917f2 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -3528,21 +3528,14 @@ blame_open(struct view *view)
        if (*opt_ref && sq_quote(ref, 0, opt_ref) >= sizeof(ref))
                return FALSE;
 
-       if (*opt_ref) {
-               if (!string_format(view->cmd, BLAME_CAT_FILE_CMD, ref, path))
-                       return FALSE;
-       } else {
-               view->pipe = fopen(opt_file, "r");
-               if (!view->pipe &&
-                   !string_format(view->cmd, BLAME_CAT_FILE_CMD, "HEAD", path))
+       if (*opt_ref || !(view->pipe = fopen(opt_file, "r"))) {
+               const char *id = *opt_ref ? ref : "HEAD";
+
+               if (!string_format(view->cmd, BLAME_CAT_FILE_CMD, id, path) ||
+                   !(view->pipe = popen(view->cmd, "r")))
                        return FALSE;
        }
 
-       if (!view->pipe)
-               view->pipe = popen(view->cmd, "r");
-       if (!view->pipe)
-               return FALSE;
-
        if (!string_format(view->cmd, BLAME_INCREMENTAL_CMD, ref, path))
                return FALSE;