Skip to content

Commit a3627be

Browse files
LorenzoPegorarigitster
authored andcommitted
repack-promisor: preserve content of promisor files after repack
When a repack involving promisor packfiles happens, the new ".promisor" file is created empty, losing all the debug info that might be present inside the ".promisor" files before the repack. Use the "copy_promisor_content()" function created previously to preserve the contents of all ".promisor" files inside the first ".promisor" file created by the repack. For geometric repacking, we have to create a `strset` that contains the basenames of all excluded packs. For "normal" repacking this is not necessary, since there should be no excluded packs. Also, update the documentation accordingly. Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 995c0e3 commit a3627be

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

Documentation/git-repack.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ other objects in that pack they already have locally.
4545
+
4646
Promisor packfiles are repacked separately: if there are packfiles that
4747
have an associated ".promisor" file, these packfiles will be repacked
48-
into another separate pack, and an empty ".promisor" file corresponding
49-
to the new separate pack will be written.
48+
into another separate pack, and a ".promisor" file corresponding to the
49+
new separate pack will be written (with arbitrary contents).
5050

5151
-A::
5252
Same as `-a`, unless `-d` is used. Then any unreachable

repack-promisor.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ static void copy_promisor_content(struct repository *repo,
153153
static void finish_repacking_promisor_objects(struct repository *repo,
154154
struct child_process *cmd,
155155
struct string_list *names,
156-
const char *packtmp)
156+
const char *packtmp,
157+
struct strset *not_repacked_basenames)
157158
{
158159
struct strbuf line = STRBUF_INIT;
159160
FILE *out;
@@ -171,19 +172,15 @@ static void finish_repacking_promisor_objects(struct repository *repo,
171172

172173
/*
173174
* pack-objects creates the .pack and .idx files, but not the
174-
* .promisor file. Create the .promisor file, which is empty.
175-
*
176-
* NEEDSWORK: fetch-pack sometimes generates non-empty
177-
* .promisor files containing the ref names and associated
178-
* hashes at the point of generation of the corresponding
179-
* packfile, but this would not preserve their contents. Maybe
180-
* concatenate the contents of all .promisor files instead of
181-
* just creating a new empty file.
175+
* .promisor file. Create the .promisor file.
182176
*/
183177
promisor_name = mkpathdup("%s-%s.promisor", packtmp,
184178
line.buf);
185179
write_promisor_file(promisor_name, NULL, 0);
186180

181+
/* Now let's fill the content of the newly created .promisor file */
182+
copy_promisor_content(repo, line.buf, packtmp, not_repacked_basenames);
183+
187184
item->util = generated_pack_populate(item->string, packtmp);
188185

189186
free(promisor_name);
@@ -223,7 +220,7 @@ void repack_promisor_objects(struct repository *repo,
223220
return;
224221
}
225222

226-
finish_repacking_promisor_objects(repo, &cmd, names, packtmp);
223+
finish_repacking_promisor_objects(repo, &cmd, names, packtmp, NULL);
227224
}
228225

229226
void pack_geometry_repack_promisors(struct repository *repo,
@@ -234,6 +231,7 @@ void pack_geometry_repack_promisors(struct repository *repo,
234231
{
235232
struct child_process cmd = CHILD_PROCESS_INIT;
236233
FILE *in;
234+
struct strset not_repacked_basenames = STRSET_INIT;
237235

238236
if (!geometry->promisor_split)
239237
return;
@@ -247,9 +245,15 @@ void pack_geometry_repack_promisors(struct repository *repo,
247245
in = xfdopen(cmd.in, "w");
248246
for (size_t i = 0; i < geometry->promisor_split; i++)
249247
fprintf(in, "%s\n", pack_basename(geometry->promisor_pack[i]));
250-
for (size_t i = geometry->promisor_split; i < geometry->promisor_pack_nr; i++)
251-
fprintf(in, "^%s\n", pack_basename(geometry->promisor_pack[i]));
248+
for (size_t i = geometry->promisor_split; i < geometry->promisor_pack_nr; i++) {
249+
const char *name = pack_basename(geometry->promisor_pack[i]);
250+
fprintf(in, "^%s\n", name);
251+
strset_add(&not_repacked_basenames, name);
252+
}
252253
fclose(in);
253254

254-
finish_repacking_promisor_objects(repo, &cmd, names, packtmp);
255+
finish_repacking_promisor_objects(repo, &cmd, names, packtmp,
256+
strset_get_size(&not_repacked_basenames) ? &not_repacked_basenames : NULL);
257+
258+
strset_clear(&not_repacked_basenames);
255259
}

0 commit comments

Comments
 (0)