Merge branch 'sh/finish-tmp-packfile'

* sh/finish-tmp-packfile:
  finish_tmp_packfile():use strbuf for pathname construction
This commit is contained in:
Junio C Hamano
2014-03-18 13:50:24 -07:00
4 changed files with 22 additions and 21 deletions

View File

@ -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));
}