]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diff.c
die_errno(): double % in strerror() output just in case
[thirdparty/git.git] / diff.c
diff --git a/diff.c b/diff.c
index dcfbcb0215766efefa786b18d793c4bf96740b8c..4d0a5b9ae6f2b5d921a2aae2a03e9a7f1616dc4d 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1964,8 +1964,16 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
 {
        int fd;
        struct strbuf buf = STRBUF_INIT;
+       struct strbuf template = STRBUF_INIT;
+       char *path_dup = xstrdup(path);
+       const char *base = basename(path_dup);
 
-       fd = git_mkstemp(temp->tmp_path, PATH_MAX, ".diff_XXXXXX");
+       /* Generate "XXXXXX_basename.ext" */
+       strbuf_addstr(&template, "XXXXXX_");
+       strbuf_addstr(&template, base);
+
+       fd = git_mkstemps(temp->tmp_path, PATH_MAX, template.buf,
+                       strlen(base) + 1);
        if (fd < 0)
                die("unable to create temp-file: %s", strerror(errno));
        if (convert_to_working_tree(path,
@@ -1981,6 +1989,8 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
        temp->hex[40] = 0;
        sprintf(temp->mode, "%06o", mode);
        strbuf_release(&buf);
+       strbuf_release(&template);
+       free(path_dup);
 }
 
 static struct diff_tempfile *prepare_temp_file(const char *name,