Merge branch 'jk/snprintf-cleanups'
Code clean-up. * jk/snprintf-cleanups: daemon: use an argv_array to exec children gc: replace local buffer with git_path transport-helper: replace checked snprintf with xsnprintf convert unchecked snprintf into xsnprintf combine-diff: replace malloc/snprintf with xstrfmt replace unchecked snprintf calls with heap buffers receive-pack: print --pack-header directly into argv array name-rev: replace static buffer with strbuf create_branch: use xstrfmt for reflog message create_branch: move msg setup closer to point of use avoid using mksnpath for refs avoid using fixed PATH_MAX buffers for refs fetch: use heap buffer to format reflog tag: use strbuf to format tag header diff: avoid fixed-size buffer for patch-ids odb_mkstemp: use git_path_buf odb_mkstemp: write filename into strbuf do not check odb_mkstemp return value for errors
This commit is contained in:
@ -1634,12 +1634,17 @@ static const char *parse_pack_header(struct pack_header *hdr)
|
||||
|
||||
static const char *pack_lockfile;
|
||||
|
||||
static void push_header_arg(struct argv_array *args, struct pack_header *hdr)
|
||||
{
|
||||
argv_array_pushf(args, "--pack_header=%"PRIu32",%"PRIu32,
|
||||
ntohl(hdr->hdr_version), ntohl(hdr->hdr_entries));
|
||||
}
|
||||
|
||||
static const char *unpack(int err_fd, struct shallow_info *si)
|
||||
{
|
||||
struct pack_header hdr;
|
||||
const char *hdr_err;
|
||||
int status;
|
||||
char hdr_arg[38];
|
||||
struct child_process child = CHILD_PROCESS_INIT;
|
||||
int fsck_objects = (receive_fsck_objects >= 0
|
||||
? receive_fsck_objects
|
||||
@ -1653,9 +1658,6 @@ static const char *unpack(int err_fd, struct shallow_info *si)
|
||||
close(err_fd);
|
||||
return hdr_err;
|
||||
}
|
||||
snprintf(hdr_arg, sizeof(hdr_arg),
|
||||
"--pack_header=%"PRIu32",%"PRIu32,
|
||||
ntohl(hdr.hdr_version), ntohl(hdr.hdr_entries));
|
||||
|
||||
if (si->nr_ours || si->nr_theirs) {
|
||||
alt_shallow_file = setup_temporary_shallow(si->shallow);
|
||||
@ -1679,7 +1681,8 @@ static const char *unpack(int err_fd, struct shallow_info *si)
|
||||
tmp_objdir_add_as_alternate(tmp_objdir);
|
||||
|
||||
if (ntohl(hdr.hdr_entries) < unpack_limit) {
|
||||
argv_array_pushl(&child.args, "unpack-objects", hdr_arg, NULL);
|
||||
argv_array_push(&child.args, "unpack-objects");
|
||||
push_header_arg(&child.args, &hdr);
|
||||
if (quiet)
|
||||
argv_array_push(&child.args, "-q");
|
||||
if (fsck_objects)
|
||||
@ -1697,8 +1700,8 @@ static const char *unpack(int err_fd, struct shallow_info *si)
|
||||
} else {
|
||||
char hostname[256];
|
||||
|
||||
argv_array_pushl(&child.args, "index-pack",
|
||||
"--stdin", hdr_arg, NULL);
|
||||
argv_array_pushl(&child.args, "index-pack", "--stdin", NULL);
|
||||
push_header_arg(&child.args, &hdr);
|
||||
|
||||
if (gethostname(hostname, sizeof(hostname)))
|
||||
xsnprintf(hostname, sizeof(hostname), "localhost");
|
||||
|
Reference in New Issue
Block a user