summaryrefslogtreecommitdiffstats
path: root/builtin/repack.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2021-01-12 09:21:59 +0100
committerJunio C Hamano <gitster@pobox.com>2021-01-13 01:01:07 +0100
commit33add2ad7d6921489aa0cafd4a865504c3709512 (patch)
tree51acf64a6a338514574e8c4e42bae3232d277ffb /builtin/repack.c
parentfetch-pack: rename helper to create_promisor_file() (diff)
downloadgit-33add2ad7d6921489aa0cafd4a865504c3709512.tar.xz
git-33add2ad7d6921489aa0cafd4a865504c3709512.zip
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 'builtin/repack.c')
-rw-r--r--builtin/repack.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/builtin/repack.c b/builtin/repack.c
index 279be11a16..2158b48f4c 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -14,6 +14,7 @@
#include "object-store.h"
#include "promisor-remote.h"
#include "shallow.h"
+#include "pack.h"
static int delta_base_offset = 1;
static int pack_kept_objects = -1;
@@ -263,7 +264,7 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
while (strbuf_getline_lf(&line, out) != EOF) {
struct string_list_item *item;
char *promisor_name;
- int fd;
+
if (line.len != the_hash_algo->hexsz)
die(_("repack: Expecting full hex object ID lines only from pack-objects."));
item = string_list_append(names, line.buf);
@@ -281,10 +282,7 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
*/
promisor_name = mkpathdup("%s-%s.promisor", packtmp,
line.buf);
- fd = open(promisor_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
- if (fd < 0)
- die_errno(_("unable to create '%s'"), promisor_name);
- close(fd);
+ write_promisor_file(promisor_name, NULL, 0);
item->util = (void *)(uintptr_t)populate_pack_exts(item->string);