| 33 | struct odb_source *, 1, fspathhash, fspatheq) |
| 34 | |
| 35 | int odb_mkstemp(struct object_database *odb, |
| 36 | struct strbuf *temp_filename, const char *pattern) |
| 37 | { |
| 38 | int fd; |
| 39 | /* |
| 40 | * we let the umask do its job, don't try to be more |
| 41 | * restrictive except to remove write permission. |
| 42 | */ |
| 43 | int mode = 0444; |
| 44 | repo_git_path_replace(odb->repo, temp_filename, "objects/%s", pattern); |
| 45 | fd = git_mkstemp_mode(temp_filename->buf, mode); |
| 46 | if (0 <= fd) |
| 47 | return fd; |
| 48 | |
| 49 | /* slow path */ |
| 50 | /* some mkstemp implementations erase temp_filename on failure */ |
| 51 | repo_git_path_replace(odb->repo, temp_filename, "objects/%s", pattern); |
| 52 | safe_create_leading_directories(odb->repo, temp_filename->buf); |
| 53 | return xmkstemp_mode(temp_filename->buf, mode); |
| 54 | } |
| 55 | |
| 56 | /* |
| 57 | * Return non-zero iff the path is usable as an alternate object database. |
no test coverage detected