commit - ef899790595636e3d4729e14971ad2843156dba9
commit + fc2a50f28951c340fb573e7fcb0646ddf93fde8f
blob - d19284b7528b98bca22ac529c892d3a3d20f34e9
blob + 7578e3c914d6acd6881cd996f0fbd10c94745f47
--- 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 - fd228f5e11199922a6911d4ffe3d24fed00cd1cc
blob + c785f4694dfc78b3ad5b5064cb0471be8ad70fae
--- 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 - aa587f957a502cfe88805538dd3b94c05b174498
blob + ddbcb7a24e9176cc112a20f881d069c75b749a37
--- 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 - 933f60daff9dfba84b076bb4d53e03af1d48831b
blob + fa7413ae8411122c7687d51f8121007fc1d7dc5c
--- 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 - 3b36523bb3fec9888a0551282782e8ec8d39d163
blob + 6edf50f52da0daa282b26ccb4fa82b57283d55bc
--- 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 - c65936153fe14c9cfc2a0ca03e30d461c2610e3b
blob + df1d59c09c18d172241755b8756c1c74925ae5b3
--- 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 - c0fc6a3072c20b18fa7a9f239b1869878c328691
blob + 2ff96da7823c45ecb7b30768597f413f7aef1b9e
--- 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 - a3c9e0c37c610e0cdcde51ed5596edaecdbafd53
blob + 4ed86484703f323b382b8d0b79090c341cec8335
--- 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 - 600aae154a6488a127d0f703ea93de4a403dfa9a
blob + 1fd814ec776b8eef26d2461d00dce965bdbbcd96
--- 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 - 3f930a7220e7a5403eeafb5e3c5ceaee7636551f
blob + bb6f7b48aba8f212300f99f8f6124870d2f9b8f4
--- 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 - 253ca4d2df8501d6a156e3e410a44b4ba19cff25
blob + 17d5e53de83220c7a4c9c4b686378fdc234de517
--- 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,