From 33add2ad7d6921489aa0cafd4a865504c3709512 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Tue, 12 Jan 2021 09:21:59 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- fetch-pack.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'fetch-pack.c') diff --git a/fetch-pack.c b/fetch-pack.c index c5fa4992a6..1eaedcb5dc 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -777,8 +777,6 @@ static void create_promisor_file(const char *keep_name, { struct strbuf promisor_name = STRBUF_INIT; int suffix_stripped; - FILE *output; - int i; strbuf_addstr(&promisor_name, keep_name); suffix_stripped = strbuf_strip_suffix(&promisor_name, ".keep"); @@ -787,11 +785,7 @@ static void create_promisor_file(const char *keep_name, keep_name); strbuf_addstr(&promisor_name, ".promisor"); - output = xfopen(promisor_name.buf, "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); + write_promisor_file(promisor_name.buf, sought, nr_sought); strbuf_release(&promisor_name); } -- cgit 1.2.3-korg