From: Jonas Fonseca Date: Wed, 31 Dec 2008 18:23:43 +0000 (-0500) Subject: Move formatting of blame --incremental command to blame_read_file X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2eb85ecd3714695835a5542386c11d55bfb29d18;p=tig.git Move formatting of blame --incremental command to blame_read_file Doing it in blame_open after starting the command makes error handling harder and the code was indeed buggy. --- diff --git a/tig.c b/tig.c index bcbc5fa..ec97f56 100644 --- a/tig.c +++ b/tig.c @@ -3536,9 +3536,6 @@ blame_open(struct view *view) return FALSE; } - if (!string_format(view->cmd, BLAME_INCREMENTAL_CMD, ref, path)) - return FALSE; - reset_view(view); string_format(view->ref, "%s ...", opt_file); string_copy_rev(view->vid, opt_file); @@ -3626,13 +3623,18 @@ static bool blame_read_file(struct view *view, const char *line, bool *read_file) { if (!line) { + char ref[SIZEOF_STR] = ""; + char path[SIZEOF_STR]; FILE *pipe = NULL; - if (view->lines > 0) - pipe = popen(view->cmd, "r"); - else if (!view->parent) + if (view->lines == 0 && !view->parent) die("No blame exist for %s", view->vid); - if (!pipe) { + + if (view->lines == 0 || + sq_quote(path, 0, opt_file) >= sizeof(path) || + (*opt_ref && sq_quote(ref, 0, opt_ref) >= sizeof(ref)) || + !string_format(view->cmd, BLAME_INCREMENTAL_CMD, ref, path) || + !(pipe = popen(view->cmd, "r"))) { report("Failed to load blame data"); return TRUE; }