diff --git a/Documentation/git-repack.adoc b/Documentation/git-repack.adoc index 72c42015e2..04ef2ad49a 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/pack-write.c b/pack-write.c index 83eaf88541..b8ab9510ff 100644 --- a/pack-write.c +++ b/pack-write.c @@ -603,6 +603,15 @@ void write_promisor_file(const char *promisor_name, struct ref **sought, int nr_ int i, err; FILE *output = xfopen(promisor_name, "w"); + /* + * Write in the .promisor file the ref names and associated hashes, + * obtained by fetch-pack, at the point of generation of the + * corresponding packfile. These pieces of info are only used to make + * it easier to debug issues with partial clones, as we can identify + * what refs (and their associated hashes) were fetched at the time + * the packfile was downloaded, and if necessary, compare those hashes + * against what the promisor remote reports now. + */ for (i = 0; i < nr_sought; i++) fprintf(output, "%s %s\n", oid_to_hex(&sought[i]->old_oid), sought[i]->name); diff --git a/repack-promisor.c b/repack-promisor.c index 90318ce150..472aef0081 100644 --- a/repack-promisor.c +++ b/repack-promisor.c @@ -1,11 +1,18 @@ #include "git-compat-util.h" #include "repack.h" +#include "hash.h" #include "hex.h" +#include "odb.h" #include "pack.h" #include "packfile.h" #include "path.h" +#include "refs.h" #include "repository.h" #include "run-command.h" +#include "strbuf.h" +#include "string-list.h" +#include "strmap.h" +#include "strvec.h" struct write_oid_context { struct child_process *cmd; @@ -34,10 +41,159 @@ static int write_oid(const struct object_id *oid, return 0; } +/* + * Go through all .promisor files contained in repo (excluding those whose name + * appears in not_repacked_basenames, which acts as a ignorelist), and copies + * their content inside the destination file "-.promisor". + * Each line of a never repacked .promisor file is: " " (as described + * in the write_promisor_file() function). + * After a repack, the copied lines will be: "