Skip to content

Commit 5e29c3f

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 83296d2 commit 5e29c3f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

builtin/pack-objects.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,8 @@ static off_t find_reused_offset(off_t where)
10131013
return reused_chunks[lo-1].difference;
10141014
}
10151015

1016-
static void write_reused_pack_one(size_t pos, struct hashfile *out,
1016+
static void write_reused_pack_one(struct packed_git *reuse_packfile,
1017+
size_t pos, struct hashfile *out,
10171018
struct pack_window **w_curs)
10181019
{
10191020
off_t offset, next, cur;
@@ -1091,7 +1092,8 @@ static void write_reused_pack_one(size_t pos, struct hashfile *out,
10911092
copy_pack_data(out, reuse_packfile, w_curs, offset, next - offset);
10921093
}
10931094

1094-
static size_t write_reused_pack_verbatim(struct hashfile *out,
1095+
static size_t write_reused_pack_verbatim(struct packed_git *reuse_packfile,
1096+
struct hashfile *out,
10951097
struct pack_window **w_curs)
10961098
{
10971099
size_t pos = 0;
@@ -1118,14 +1120,15 @@ static size_t write_reused_pack_verbatim(struct hashfile *out,
11181120
return pos;
11191121
}
11201122

1121-
static void write_reused_pack(struct hashfile *f)
1123+
static void write_reused_pack(struct packed_git *reuse_packfile,
1124+
struct hashfile *f)
11221125
{
11231126
size_t i = 0;
11241127
uint32_t offset;
11251128
struct pack_window *w_curs = NULL;
11261129

11271130
if (allow_ofs_delta)
1128-
i = write_reused_pack_verbatim(f, &w_curs);
1131+
i = write_reused_pack_verbatim(reuse_packfile, f, &w_curs);
11291132

11301133
for (; i < reuse_packfile_bitmap->word_alloc; ++i) {
11311134
eword_t word = reuse_packfile_bitmap->words[i];
@@ -1141,7 +1144,8 @@ static void write_reused_pack(struct hashfile *f)
11411144
* bitmaps. See comment in try_partial_reuse()
11421145
* for why.
11431146
*/
1144-
write_reused_pack_one(pos + offset, f, &w_curs);
1147+
write_reused_pack_one(reuse_packfile, pos + offset, f,
1148+
&w_curs);
11451149
display_progress(progress_state, ++written);
11461150
}
11471151
}
@@ -1199,7 +1203,7 @@ static void write_pack_file(void)
11991203

12001204
if (reuse_packfile) {
12011205
assert(pack_to_stdout);
1202-
write_reused_pack(f);
1206+
write_reused_pack(reuse_packfile, f);
12031207
offset = hashfile_total(f);
12041208
}
12051209

0 commit comments

Comments
 (0)