]> git.ipfire.org Git - thirdparty/git.git/blobdiff - range-diff.c
range-diff: avoid negative string precision
[thirdparty/git.git] / range-diff.c
index 5cc920be391d2e93a69899e8e6e4b487fbefa0a3..40af0862818c15d6c432da1d02fbe1ba7cadf230 100644 (file)
@@ -123,16 +123,19 @@ static int read_patches(const char *range, struct string_list *list,
                        struct patch patch = { 0 };
                        struct strbuf root = STRBUF_INIT;
                        int linenr = 0;
+                       int orig_len;
 
                        in_header = 0;
                        strbuf_addch(&buf, '\n');
                        if (!util->diff_offset)
                                util->diff_offset = buf.len;
                        line[len - 1] = '\n';
+                       orig_len = len;
                        len = parse_git_diff_header(&root, &linenr, 0, line,
                                                    len, size, &patch);
                        if (len < 0)
-                               die(_("could not parse git header '%.*s'"), (int)len, line);
+                               die(_("could not parse git header '%.*s'"),
+                                   orig_len, line);
                        strbuf_addstr(&buf, " ## ");
                        if (patch.is_new > 0)
                                strbuf_addf(&buf, "%s (new)", patch.new_name);