diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-03-18 13:50:24 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-03-18 13:50:24 -0700 |
commit | f4eec8ce05e725a5e30d3d29c47093d4e3e0ce7e (patch) | |
tree | e182b41c38aae7305a0df318993fce757caf6733 /builtin | |
parent | Merge branch 'dd/use-alloc-grow' (diff) | |
parent | finish_tmp_packfile():use strbuf for pathname construction (diff) | |
download | tgif-f4eec8ce05e725a5e30d3d29c47093d4e3e0ce7e.tar.xz |
Merge branch 'sh/finish-tmp-packfile'
* sh/finish-tmp-packfile:
finish_tmp_packfile():use strbuf for pathname construction
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/pack-objects.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 057c54b902..61a55b3c7e 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -803,7 +803,7 @@ static void write_pack_file(void) if (!pack_to_stdout) { struct stat st; - char tmpname[PATH_MAX]; + struct strbuf tmpname = STRBUF_INIT; /* * Packs are runtime accessed in their mtime @@ -826,23 +826,19 @@ static void write_pack_file(void) pack_tmp_name, strerror(errno)); } - /* Enough space for "-<sha-1>.pack"? */ - if (sizeof(tmpname) <= strlen(base_name) + 50) - die("pack base name '%s' too long", base_name); - snprintf(tmpname, sizeof(tmpname), "%s-", base_name); + strbuf_addf(&tmpname, "%s-", base_name); if (write_bitmap_index) { bitmap_writer_set_checksum(sha1); bitmap_writer_build_type_index(written_list, nr_written); } - finish_tmp_packfile(tmpname, pack_tmp_name, + finish_tmp_packfile(&tmpname, pack_tmp_name, written_list, nr_written, &pack_idx_opts, sha1); if (write_bitmap_index) { - char *end_of_name_prefix = strrchr(tmpname, 0); - sprintf(end_of_name_prefix, "%s.bitmap", sha1_to_hex(sha1)); + strbuf_addf(&tmpname, "%s.bitmap", sha1_to_hex(sha1)); stop_progress(&progress_state); @@ -851,10 +847,11 @@ static void write_pack_file(void) bitmap_writer_select_commits(indexed_commits, indexed_commits_nr, -1); bitmap_writer_build(&to_pack); bitmap_writer_finish(written_list, nr_written, - tmpname, write_bitmap_options); + tmpname.buf, write_bitmap_options); write_bitmap_index = 0; } + strbuf_release(&tmpname); free(pack_tmp_name); puts(sha1_to_hex(sha1)); } |