summaryrefslogtreecommitdiff
path: root/pack-write.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2021-01-12 08:21:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-13 00:01:07 (GMT)
commit33add2ad7d6921489aa0cafd4a865504c3709512 (patch)
tree51acf64a6a338514574e8c4e42bae3232d277ffb /pack-write.c
parent9d7fa3be3145f1ad87bf5d4ddbf6ce8cb0e6a894 (diff)
downloadgit-33add2ad7d6921489aa0cafd4a865504c3709512.zip
git-33add2ad7d6921489aa0cafd4a865504c3709512.tar.gz
git-33add2ad7d6921489aa0cafd4a865504c3709512.tar.bz2
fetch-pack: refactor writing promisor file
Let's replace the 2 different pieces of code that write a promisor file in 'builtin/repack.c' and 'fetch-pack.c' with a new function called 'write_promisor_file()' in 'pack-write.c' and 'pack.h'. This might also help us in the future, if we want to put back the ref names and associated hashes that were in the promisor files we are repacking in 'builtin/repack.c' as suggested by a NEEDSWORK comment just above the code we are refactoring. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-write.c')
-rw-r--r--pack-write.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/pack-write.c b/pack-write.c
index 3513665..db3ff99 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "pack.h"
#include "csum-file.h"
+#include "remote.h"
void reset_pack_idx_option(struct pack_idx_option *opts)
{
@@ -367,3 +368,14 @@ void finish_tmp_packfile(struct strbuf *name_buffer,
free((void *)idx_tmp_name);
}
+
+void write_promisor_file(const char *promisor_name, struct ref **sought, int nr_sought)
+{
+ int i;
+ FILE *output = xfopen(promisor_name, "w");
+
+ for (i = 0; i < nr_sought; i++)
+ fprintf(output, "%s %s\n", oid_to_hex(&sought[i]->old_oid),
+ sought[i]->name);
+ fclose(output);
+}