mirror of
https://github.com/git/git.git
synced 2024-11-24 10:26:17 +08:00
pack-objects: parameterize pack-reuse routines over a single pack
The routines pack-objects uses to perform verbatim pack-reuse are: - write_reused_pack_one() - write_reused_pack_verbatim() - write_reused_pack() , all of which assume that there is exactly one packfile being reused: the global constant `reuse_packfile`. Prepare for reusing objects from multiple packs by making reuse packfile a parameter of each of the above functions in preparation for calling these functions in a loop with multiple packfiles. Note that we still have the global "reuse_packfile", but pass it through each of the above function's parameter lists, eliminating all but one direct access (the top-level caller in `write_pack_file()`). Even after this series, we will still have a global, but it will hold the array of reusable packfiles, and we'll pass them one at a time to these functions in a loop. Note also that we will eventually need to pass a `bitmapped_pack` instead of a `packed_git` in order to hold onto additional information required for reuse (such as the bit position of the first object belonging to that pack). But that change will be made in a future commit so as to minimize the noise below as much as possible. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
83296d20e8
commit
5e29c3f707
@ -1013,7 +1013,8 @@ static off_t find_reused_offset(off_t where)
|
||||
return reused_chunks[lo-1].difference;
|
||||
}
|
||||
|
||||
static void write_reused_pack_one(size_t pos, struct hashfile *out,
|
||||
static void write_reused_pack_one(struct packed_git *reuse_packfile,
|
||||
size_t pos, struct hashfile *out,
|
||||
struct pack_window **w_curs)
|
||||
{
|
||||
off_t offset, next, cur;
|
||||
@ -1091,7 +1092,8 @@ static void write_reused_pack_one(size_t pos, struct hashfile *out,
|
||||
copy_pack_data(out, reuse_packfile, w_curs, offset, next - offset);
|
||||
}
|
||||
|
||||
static size_t write_reused_pack_verbatim(struct hashfile *out,
|
||||
static size_t write_reused_pack_verbatim(struct packed_git *reuse_packfile,
|
||||
struct hashfile *out,
|
||||
struct pack_window **w_curs)
|
||||
{
|
||||
size_t pos = 0;
|
||||
@ -1118,14 +1120,15 @@ static size_t write_reused_pack_verbatim(struct hashfile *out,
|
||||
return pos;
|
||||
}
|
||||
|
||||
static void write_reused_pack(struct hashfile *f)
|
||||
static void write_reused_pack(struct packed_git *reuse_packfile,
|
||||
struct hashfile *f)
|
||||
{
|
||||
size_t i = 0;
|
||||
uint32_t offset;
|
||||
struct pack_window *w_curs = NULL;
|
||||
|
||||
if (allow_ofs_delta)
|
||||
i = write_reused_pack_verbatim(f, &w_curs);
|
||||
i = write_reused_pack_verbatim(reuse_packfile, f, &w_curs);
|
||||
|
||||
for (; i < reuse_packfile_bitmap->word_alloc; ++i) {
|
||||
eword_t word = reuse_packfile_bitmap->words[i];
|
||||
@ -1141,7 +1144,8 @@ static void write_reused_pack(struct hashfile *f)
|
||||
* bitmaps. See comment in try_partial_reuse()
|
||||
* for why.
|
||||
*/
|
||||
write_reused_pack_one(pos + offset, f, &w_curs);
|
||||
write_reused_pack_one(reuse_packfile, pos + offset, f,
|
||||
&w_curs);
|
||||
display_progress(progress_state, ++written);
|
||||
}
|
||||
}
|
||||
@ -1199,7 +1203,7 @@ static void write_pack_file(void)
|
||||
|
||||
if (reuse_packfile) {
|
||||
assert(pack_to_stdout);
|
||||
write_reused_pack(f);
|
||||
write_reused_pack(reuse_packfile, f);
|
||||
offset = hashfile_total(f);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user