[GSoC PATCH v2 3/4] repack-promisor: preserve content of promisor files after repack
- From
LorenzoPegorari <lorenzo.pegorari2002@gmail.com>
- Date
- Mar 22, 2026, 19:18 UTC
- Message-ID
- <3dab969a3942532f49f6f9cdcddb5fb2be11e232.1774205661.git.lorenzo.pegorari2002@gmail.com>
- In-Reply-To
- <cover.1774205661.git.lorenzo.pegorari2002@gmail.com>
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_all_promisor_files()" function created previously to preserve the contents of all ".promisor" files inside the first ".promisor" file created by the repack.
Also, update the documentation accordingly.
Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com> --- Documentation/git-repack.adoc | 4 ++-- repack-promisor.c | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/Documentation/git-repack.adoc b/Documentation/git-repack.adoc index 673ce91083..33d3c8afbd 100644 --- a/Documentation/git-repack.adoc +++ b/Documentation/git-repack.adoc @@ -45,8 +45,8 @@ other objects in that pack they already have locally. + Promisor packfiles are repacked separately: if there are packfiles that have an associated ".promisor" file, these packfiles will be repacked -into another separate pack, and an empty ".promisor" file corresponding -to the new separate pack will be written. +into another separate pack, and a ".promisor" file corresponding to the +new separate pack will be written (with arbitrary contents). -A:: Same as `-a`, unless `-d` is used. Then any unreachable diff --git a/repack-promisor.c b/repack-promisor.c index 90318ce150..6670728669 100644 --- a/repack-promisor.c +++ b/repack-promisor.c @@ -40,6 +40,7 @@ static void finish_repacking_promisor_objects(struct repository *repo, const char *packtmp) { struct strbuf line = STRBUF_INIT; + int is_first_promisor = 1; FILE *out; close(cmd->in); @@ -55,19 +56,25 @@ static void finish_repacking_promisor_objects(struct repository *repo, /* * pack-objects creates the .pack and .idx files, but not the - * .promisor file. Create the .promisor file, which is empty. - * - * NEEDSWORK: fetch-pack sometimes generates non-empty - * .promisor files containing the ref names and associated - * hashes at the point of generation of the corresponding - * packfile, but this would not preserve their contents. Maybe - * concatenate the contents of all .promisor files instead of - * just creating a new empty file. + * .promisor file. Create the .promisor file. */ promisor_name = mkpathdup("%s-%s.promisor", packtmp, line.buf); write_promisor_file(promisor_name, NULL, 0); + /* + * Fetch-pack sometimes generates non-empty .promisor files + * containing the ref names and associated hashes at the point of + * generation of the corresponding packfile. These pieces of info + * are only used for debugging reasons. In order to preserve + * these, let's copy the contents of all .promisor files in the + * first promisor file created. + */ + if (is_first_promisor) { + copy_all_promisor_files(repo, promisor_name); + is_first_promisor = 0; + } + item->util = generated_pack_populate(item->string, packtmp); free(promisor_name);
-- 2.43.0