diff options
Diffstat (limited to 'pack-bitmap-write.c')
-rw-r--r-- | pack-bitmap-write.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index c05d1386af..8e47a96b3b 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -73,7 +73,8 @@ void bitmap_writer_build_type_index(struct pack_idx_entry **index, break; default: - real_type = sha1_object_info(entry->idx.sha1, NULL); + real_type = sha1_object_info(entry->idx.oid.hash, + NULL); break; } @@ -96,7 +97,8 @@ void bitmap_writer_build_type_index(struct pack_idx_entry **index, default: die("Missing type information for %s (%d/%d)", - sha1_to_hex(entry->idx.sha1), real_type, entry->type); + oid_to_hex(&entry->idx.oid), real_type, + entry->type); } } } @@ -148,11 +150,10 @@ static uint32_t find_object_pos(const unsigned char *sha1) return entry->in_pack_pos; } -static void show_object(struct object *object, const struct name_path *path, - const char *last, void *data) +static void show_object(struct object *object, const char *name, void *data) { struct bitmap *base = data; - bitmap_set(base, find_object_pos(object->sha1)); + bitmap_set(base, find_object_pos(object->oid.hash)); mark_as_seen(object); } @@ -165,12 +166,12 @@ static int add_to_include_set(struct bitmap *base, struct commit *commit) { khiter_t hash_pos; - uint32_t bitmap_pos = find_object_pos(commit->object.sha1); + uint32_t bitmap_pos = find_object_pos(commit->object.oid.hash); if (bitmap_get(base, bitmap_pos)) return 0; - hash_pos = kh_get_sha1(writer.bitmaps, commit->object.sha1); + hash_pos = kh_get_sha1(writer.bitmaps, commit->object.oid.hash); if (hash_pos < kh_end(writer.bitmaps)) { struct bitmapped_commit *bc = kh_value(writer.bitmaps, hash_pos); bitmap_or_ewah(base, bc->bitmap); @@ -308,10 +309,10 @@ void bitmap_writer_build(struct packing_data *to_pack) if (i >= reuse_after) stored->flags |= BITMAP_FLAG_REUSE; - hash_pos = kh_put_sha1(writer.bitmaps, object->sha1, &hash_ret); + hash_pos = kh_put_sha1(writer.bitmaps, object->oid.hash, &hash_ret); if (hash_ret == 0) die("Duplicate entry when writing index: %s", - sha1_to_hex(object->sha1)); + oid_to_hex(&object->oid)); kh_value(writer.bitmaps, hash_pos) = stored; display_progress(writer.progress, writer.selected_nr - i); @@ -386,8 +387,7 @@ void bitmap_writer_select_commits(struct commit **indexed_commits, { unsigned int i = 0, j, next; - qsort(indexed_commits, indexed_commits_nr, sizeof(indexed_commits[0]), - date_compare); + QSORT(indexed_commits, indexed_commits_nr, date_compare); if (writer.show_progress) writer.progress = start_progress("Selecting bitmap commits", 0); @@ -414,14 +414,14 @@ void bitmap_writer_select_commits(struct commit **indexed_commits, if (next == 0) { chosen = indexed_commits[i]; - reused_bitmap = find_reused_bitmap(chosen->object.sha1); + reused_bitmap = find_reused_bitmap(chosen->object.oid.hash); } else { chosen = indexed_commits[i + next]; for (j = 0; j <= next; ++j) { struct commit *cm = indexed_commits[i + j]; - reused_bitmap = find_reused_bitmap(cm->object.sha1); + reused_bitmap = find_reused_bitmap(cm->object.oid.hash); if (reused_bitmap || (cm->object.flags & NEEDS_BITMAP) != 0) { chosen = cm; break; @@ -461,7 +461,7 @@ static inline void dump_bitmap(struct sha1file *f, struct ewah_bitmap *bitmap) static const unsigned char *sha1_access(size_t pos, void *table) { struct pack_idx_entry **index = table; - return index[pos]->sha1; + return index[pos]->oid.hash; } static void write_selected_commits_v1(struct sha1file *f, @@ -474,7 +474,7 @@ static void write_selected_commits_v1(struct sha1file *f, struct bitmapped_commit *stored = &writer.selected[i]; int commit_pos = - sha1_pos(stored->commit->object.sha1, index, index_nr, sha1_access); + sha1_pos(stored->commit->object.oid.hash, index, index_nr, sha1_access); if (commit_pos < 0) die("BUG: trying to write commit not in index"); @@ -510,18 +510,16 @@ void bitmap_writer_finish(struct pack_idx_entry **index, const char *filename, uint16_t options) { - static char tmp_file[PATH_MAX]; static uint16_t default_version = 1; static uint16_t flags = BITMAP_OPT_FULL_DAG; + struct strbuf tmp_file = STRBUF_INIT; struct sha1file *f; struct bitmap_disk_header header; - int fd = odb_mkstemp(tmp_file, sizeof(tmp_file), "pack/tmp_bitmap_XXXXXX"); + int fd = odb_mkstemp(&tmp_file, "pack/tmp_bitmap_XXXXXX"); - if (fd < 0) - die_errno("unable to create '%s'", tmp_file); - f = sha1fd(fd, tmp_file); + f = sha1fd(fd, tmp_file.buf); memcpy(header.magic, BITMAP_IDX_SIGNATURE, sizeof(BITMAP_IDX_SIGNATURE)); header.version = htons(default_version); @@ -541,9 +539,11 @@ void bitmap_writer_finish(struct pack_idx_entry **index, sha1close(f, NULL, CSUM_FSYNC); - if (adjust_shared_perm(tmp_file)) + if (adjust_shared_perm(tmp_file.buf)) die_errno("unable to make temporary bitmap file readable"); - if (rename(tmp_file, filename)) + if (rename(tmp_file.buf, filename)) die_errno("unable to rename temporary bitmap file to '%s'", filename); + + strbuf_release(&tmp_file); } |