diff options
Diffstat (limited to 'entry.c')
-rw-r--r-- | entry.c | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -6,7 +6,7 @@ static void create_directories(const char *path, int path_len, const struct checkout *state) { - char *buf = xmalloc(path_len + 1); + char *buf = xmallocz(path_len); int len = 0; while (len < path_len) { @@ -82,7 +82,7 @@ static int create_file(const char *path, unsigned int mode) static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size) { enum object_type type; - void *new = read_sha1_file(ce->sha1, &type, size); + void *new = read_sha1_file(ce->oid.hash, &type, size); if (new) { if (type == OBJ_BLOB) @@ -96,8 +96,8 @@ static int open_output_fd(char *path, const struct cache_entry *ce, int to_tempf { int symlink = (ce->ce_mode & S_IFMT) != S_IFREG; if (to_tempfile) { - strcpy(path, symlink - ? ".merge_link_XXXXXX" : ".merge_file_XXXXXX"); + xsnprintf(path, TEMPORARY_FILENAME_LENGTH, "%s", + symlink ? ".merge_link_XXXXXX" : ".merge_file_XXXXXX"); return mkstemp(path); } else { return create_file(path, !symlink ? ce->ce_mode : 0666); @@ -127,7 +127,7 @@ static int streaming_write_entry(const struct cache_entry *ce, char *path, if (fd < 0) return -1; - result |= stream_blob_to_fd(fd, ce->sha1, filter, 1); + result |= stream_blob_to_fd(fd, &ce->oid, filter, 1); *fstat_done = fstat_output(fd, state, statbuf); result |= close(fd); @@ -148,7 +148,8 @@ static int write_entry(struct cache_entry *ce, struct stat st; if (ce_mode_s_ifmt == S_IFREG) { - struct stream_filter *filter = get_stream_filter(ce->name, ce->sha1); + struct stream_filter *filter = get_stream_filter(ce->name, + ce->oid.hash); if (filter && !streaming_write_entry(ce, path, filter, state, to_tempfile, @@ -162,14 +163,14 @@ static int write_entry(struct cache_entry *ce, new = read_blob_entry(ce, &size); if (!new) return error("unable to read sha1 file of %s (%s)", - path, sha1_to_hex(ce->sha1)); + path, oid_to_hex(&ce->oid)); if (ce_mode_s_ifmt == S_IFLNK && has_symlinks && !to_tempfile) { ret = symlink(new, path); free(new); if (ret) - return error("unable to create symlink %s (%s)", - path, strerror(errno)); + return error_errno("unable to create symlink %s", + path); break; } @@ -186,8 +187,7 @@ static int write_entry(struct cache_entry *ce, fd = open_output_fd(path, ce, to_tempfile); if (fd < 0) { free(new); - return error("unable to create file %s (%s)", - path, strerror(errno)); + return error_errno("unable to create file %s", path); } wrote = write_in_full(fd, new, size); @@ -284,8 +284,7 @@ int checkout_entry(struct cache_entry *ce, return error("%s is a directory", path.buf); remove_subtree(&path); } else if (unlink(path.buf)) - return error("unable to unlink old '%s' (%s)", - path.buf, strerror(errno)); + return error_errno("unable to unlink old '%s'", path.buf); } else if (state->not_new) return 0; |