commit - 2a47b1e5852390eadc730c1dd2dd7caae011adfa
commit + b90054ed55f30ebe28115abf5ad9cecc2b925713
blob - cbfb69469133d43ff6d3185d620a4cfc74627a59
blob + c0c38ea47dfbd657ee0c14d0e8829767ad691ae6
--- got/got.c
+++ got/got.c
return got_error_from_errno("asprintf");
err = got_opentemp_named_fd(logmsg_path, &fd,
- GOT_TMPDIR_STR "/got-importmsg");
+ GOT_TMPDIR_STR "/got-importmsg", "");
if (err)
goto done;
goto done;
}
- err = got_opentemp_named_fd(tagmsg_path, &fd, template);
+ err = got_opentemp_named_fd(tagmsg_path, &fd, template, "");
if (err)
goto done;
if (asprintf(&template, "%s/logmsg", a->worktree_path) == -1)
return got_error_from_errno("asprintf");
- err = got_opentemp_named_fd(&a->logmsg_path, &fd, template);
+ err = got_opentemp_named_fd(&a->logmsg_path, &fd, template, "");
if (err)
goto done;
goto done;
err = got_opentemp_named_fd(&logmsg_path, &fd,
- GOT_TMPDIR_STR "/got-logmsg");
+ GOT_TMPDIR_STR "/got-logmsg", "");
if (err)
goto done;
FILE *f = NULL;
char *path = NULL;
- err = got_opentemp_named(&path, &f, "got-histedit");
+ err = got_opentemp_named(&path, &f, "got-histedit", "");
if (err)
return err;
blob - 59fe03f76be46a82ab9cd7fb0b540b1181364a76
blob + faaafb6f3ed653a3a12f8ac342ab54ce2f43d2c0
--- gotd/gotd.c
+++ gotd/gotd.c
goto done;
}
- err = got_opentemp_named_fd(&pack_path, &packfd, basepath);
+ err = got_opentemp_named_fd(&pack_path, &packfd, basepath, "");
if (err)
goto done;
basepath = NULL;
goto done;
}
- err = got_opentemp_named_fd(&idx_path, &idxfd, basepath);
+ err = got_opentemp_named_fd(&idx_path, &idxfd, basepath, "");
if (err)
goto done;
blob - 5df60c352cb02c68869dfd77742c78669f368df6
blob + 8c49224c3f3618922f155e0671044215eba5d031
--- include/got_opentemp.h
+++ include/got_opentemp.h
/* Open a new temporary file for writing.
* The file is visible in the filesystem. */
-const struct got_error *got_opentemp_named(char **, FILE **, const char *);
+const struct got_error *got_opentemp_named(char **, FILE **, const char *,
+ const char *);
/* Like got_opentemp_named() but returns a file descriptor instead of a FILE. */
-const struct got_error *got_opentemp_named_fd(char **, int *, const char *);
+const struct got_error *got_opentemp_named_fd(char **, int *, const char *,
+ const char *);
/* Truncate a file. This is useful for re-using open temporary files. */
const struct got_error *got_opentemp_truncate(FILE *);
blob - ca41b5e1c959efef486c9c9c470cd918d4390b7f
blob + 4570818661d209d2a903214f7ca0611c3da485eb
--- lib/diff3.c
+++ lib/diff3.c
}
err = got_opentemp_named(&outpath, &outfile,
- GOT_TMPDIR_STR "/got-diffreg");
+ GOT_TMPDIR_STR "/got-diffreg", "");
if (err)
goto done;
blob - 897d9da4c5d2cbbf863779e67af4ba3faeb6ae40
blob + 0dd641076040553ff06ef8320ae4686dabdd6786
--- lib/fetch.c
+++ lib/fetch.c
err = got_error_from_errno("asprintf");
goto done;
}
- err = got_opentemp_named_fd(&tmppackpath, &packfd, path);
+ err = got_opentemp_named_fd(&tmppackpath, &packfd, path, "");
free(path);
if (err)
goto done;
err = got_error_from_errno("asprintf");
goto done;
}
- err = got_opentemp_named_fd(&tmpidxpath, &idxfd, path);
+ err = got_opentemp_named_fd(&tmpidxpath, &idxfd, path, "");
free(path);
if (err)
goto done;
blob - 670e15b4f8e9326fc92edea6272e06bd3e072a60
blob + 8fa42a873d1dd3feb591275a17e1bd546c3dab59
--- lib/object_create.c
+++ lib/object_create.c
if (err)
return err;
- err = got_opentemp_named(&tmppath, &tmpfile, objpath);
+ err = got_opentemp_named(&tmppath, &tmpfile, objpath, "");
if (err) {
char *parent_path;
if (!(err->code == GOT_ERR_ERRNO && errno == ENOENT))
free(parent_path);
if (err)
goto done;
- err = got_opentemp_named(&tmppath, &tmpfile, objpath);
+ err = got_opentemp_named(&tmppath, &tmpfile, objpath, "");
if (err)
goto done;
}
blob - 3c1f5eebe793a2f895a8529b13cdad48e3f9ccb0
blob + 0e4865ca9ef8a0f80cc03e76722c8280c20510bf
--- lib/opentemp.c
+++ lib/opentemp.c
}
const struct got_error *
-got_opentemp_named(char **path, FILE **outfile, const char *basepath)
+got_opentemp_named(char **path, FILE **outfile, const char *basepath,
+ const char *suffix)
{
const struct got_error *err = NULL;
int fd;
*outfile = NULL;
- if (asprintf(path, "%s-XXXXXX", basepath) == -1) {
+ if (asprintf(path, "%s-XXXXXX%s", basepath, suffix) == -1) {
*path = NULL;
return got_error_from_errno("asprintf");
}
- fd = mkstemp(*path);
+ fd = mkstemps(*path, strlen(suffix));
if (fd == -1) {
- err = got_error_from_errno2("mkstemp", *path);
+ err = got_error_from_errno2("mkstemps", *path);
free(*path);
*path = NULL;
return err;
}
const struct got_error *
-got_opentemp_named_fd(char **path, int *outfd, const char *basepath)
+got_opentemp_named_fd(char **path, int *outfd, const char *basepath,
+ const char *suffix)
{
const struct got_error *err = NULL;
int fd;
*outfd = -1;
- if (asprintf(path, "%s-XXXXXX", basepath) == -1) {
+ if (asprintf(path, "%s-XXXXXX%s", basepath, suffix) == -1) {
*path = NULL;
return got_error_from_errno("asprintf");
}
- fd = mkstemp(*path);
+ fd = mkstemps(*path, strlen(suffix));
if (fd == -1) {
err = got_error_from_errno("mkstemp");
free(*path);
blob - 8647dea45a83ad12f49ae63960dd903bd55fde98
blob + 6c31c4b5e3788850c30c78ed552e90f1eddd3982
--- lib/patch.c
+++ lib/patch.c
if (err)
goto done;
- err = got_opentemp_named(path, fp, GOT_TMPDIR_STR "/got-patch-blob");
+ err = got_opentemp_named(path, fp, GOT_TMPDIR_STR "/got-patch-blob",
+ "");
if (err)
goto done;
} else if (p->xbit)
mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
- err = got_opentemp_named(&tmppath, &tmpfile, template);
+ err = got_opentemp_named(&tmppath, &tmpfile, template, "");
if (err)
goto done;
outfd = fileno(tmpfile);
tmpfile = t;
}
- err = got_opentemp_named(&mergepath, &mergefile, template);
+ err = got_opentemp_named(&mergepath, &mergefile, template, "");
if (err)
goto done;
outfd = fileno(mergefile);
blob - b5f93d7b7eba07c7f32fdad87614319943f14305
blob + 63312071b7d892680d8127151e9958aed8e85ac8
--- lib/reference.c
+++ lib/reference.c
goto done;
}
- err = got_opentemp_named(&tmppath, &f, path);
+ err = got_opentemp_named(&tmppath, &f, path, "");
if (err) {
char *parent;
if (!(err->code == GOT_ERR_ERRNO && errno == ENOENT))
free(parent);
if (err)
goto done;
- err = got_opentemp_named(&tmppath, &f, path);
+ err = got_opentemp_named(&tmppath, &f, path, "");
if (err)
goto done;
}
if (packed_refs_path == NULL)
return got_error_from_errno("got_repo_get_path_packed_refs");
- err = got_opentemp_named(&tmppath, &tmpf, packed_refs_path);
+ err = got_opentemp_named(&tmppath, &tmpf, packed_refs_path, "");
if (err)
goto done;
blob - 8486282d50b2fc83c3f3b444373cd17540fd31dd
blob + fd1fae8ec1b8171b5cb576110a381201f1cb4ad9
--- lib/repository_admin.c
+++ lib/repository_admin.c
err = got_error_from_errno("asprintf");
goto done;
}
- err = got_opentemp_named_fd(&tmpfile_path, &packfd, path);
+ err = got_opentemp_named_fd(&tmpfile_path, &packfd, path, "");
if (err)
goto done;
err = got_error_from_errno("asprintf");
goto done;
}
- err = got_opentemp_named_fd(&tmpidxpath, &idxfd, path);
+ err = got_opentemp_named_fd(&tmpidxpath, &idxfd, path, "");
free(path);
if (err)
goto done;
blob - 3800e67fcce500f30b32b4c3590bdf0493827da1
blob + 8bcb3732e23d2041a0bd0790d942ce3377f22b68
--- lib/sigs.c
+++ lib/sigs.c
*msg = NULL;
error = got_opentemp_named(&tmppath, &tmpsig,
- GOT_TMPDIR_STR "/got-tagsig");
+ GOT_TMPDIR_STR "/got-tagsig", "");
if (error)
goto done;
blob - acbca91c5f5f7a0048daf2e2b2baffaf08c347d5
blob + 929c300ef8767589d0f0aa5a4db85d85655e794f
--- lib/worktree.c
+++ lib/worktree.c
goto done;
}
- err = got_opentemp_named(&tmppath, &tmpfile, path);
+ err = got_opentemp_named(&tmppath, &tmpfile, path, "");
if (err)
goto done;
goto done;
}
err = got_opentemp_named_fd(&path_orig, &fd_orig,
- base_path_orig);
+ base_path_orig, "");
if (err)
goto done;
err = got_opentemp_named_fd(&path_deriv, &fd_deriv,
- base_path_deriv);
+ base_path_deriv, "");
if (err)
goto done;
err = got_opentemp_named_fd(&path_deriv2, &fd_deriv2,
- base_path_deriv2);
+ base_path_deriv2, "");
if (err)
goto done;
err = copy_file_to_fd(&size_orig, f_orig, fd_orig);
goto done;
}
- err = got_opentemp_named_fd(&merged_path, &merged_fd, base_path);
+ err = got_opentemp_named_fd(&merged_path, &merged_fd, base_path, "");
if (err)
goto done;
goto done;
}
- err = got_opentemp_named(&path, &f, "got-symlink-conflict");
+ err = got_opentemp_named(&path, &f, "got-symlink-conflict", "");
if (err)
goto done;
goto done;
}
- err = got_opentemp_named(&blob_orig_path, &f_orig, base_path);
+ err = got_opentemp_named(&blob_orig_path, &f_orig,
+ base_path, "");
if (err)
goto done;
err = got_object_blob_dump_to_file(NULL, NULL, NULL, f_orig,
goto done;
}
- err = got_opentemp_named(&blob_deriv_path, &f_deriv, base_path);
+ err = got_opentemp_named(&blob_deriv_path, &f_deriv, base_path, "");
if (err)
goto done;
err = got_object_blob_dump_to_file(NULL, NULL, NULL, f_deriv,
goto done;
} else {
err = got_opentemp_named_fd(&tmppath, &fd,
- ondisk_path);
+ ondisk_path, "");
if (err)
goto done;
update = 1;
struct timespec timeout;
err = got_opentemp_named(&new_fileindex_path, &new_index,
- fileindex_path);
+ fileindex_path, "");
if (err)
goto done;
if (err)
goto done;
- err = got_opentemp_named(&path1, &f1, "got-patched-blob");
+ err = got_opentemp_named(&path1, &f1, "got-patched-blob", "");
if (err)
goto done;
if (err)
goto done;
- err = got_opentemp_named(path_outfile, &outfile, "got-patched-content");
+ err = got_opentemp_named(path_outfile, &outfile, "got-patched-content",
+ "");
if (err)
goto done;
cc_arg.diff_header_shown = 0;
if (show_diff) {
err = got_opentemp_named(&diff_path, &cc_arg.diff_outfile,
- GOT_TMPDIR_STR "/got-diff");
+ GOT_TMPDIR_STR "/got", ".diff");
if (err)
goto done;
cc_arg.f1 = got_opentemp();
if (err)
goto done;
- err = got_opentemp_named(&path1, &f1, "got-unstage-blob-base");
+ err = got_opentemp_named(&path1, &f1, "got-unstage-blob-base", "");
if (err)
goto done;
if (err)
goto done;
- err = got_opentemp_named(&path2, &f2, "got-unstage-blob-staged");
+ err = got_opentemp_named(&path2, &f2, "got-unstage-blob-staged", "");
if (err)
goto done;
goto done;
err = got_opentemp_named(path_unstaged_content, &outfile,
- "got-unstaged-content");
+ "got-unstaged-content", "");
if (err)
goto done;
err = got_opentemp_named(path_new_staged_content, &rejectfile,
- "got-new-staged-content");
+ "got-new-staged-content", "");
if (err)
goto done;
goto done;
}
- err = got_opentemp_named(&blob_base_path, &f_base, base_path);
+ err = got_opentemp_named(&blob_base_path, &f_base,
+ base_path, "");
if (err)
goto done;
err = got_object_blob_dump_to_file(NULL, NULL, NULL, f_base,