summaryrefslogtreecommitdiff
path: root/pack-write.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-09-09 23:24:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-10 01:23:11 (GMT)
commit2ec02dd5a8261bc837b961ef36788081ded5c2bc (patch)
tree3a6833d249e52901e8064c1865e47350b4462ff3 /pack-write.c
parent522a5c2cf542dedbdd51d08c1452b5cbdbbc2809 (diff)
downloadgit-2ec02dd5a8261bc837b961ef36788081ded5c2bc.zip
git-2ec02dd5a8261bc837b961ef36788081ded5c2bc.tar.gz
git-2ec02dd5a8261bc837b961ef36788081ded5c2bc.tar.bz2
pack-write: split up finish_tmp_packfile() function
Split up the finish_tmp_packfile() function and use the split-up version in pack-objects.c in preparation for moving the step of renaming the *.idx file later as part of a function change. Since the only other caller of finish_tmp_packfile() was in bulk-checkin.c, and it won't be needing a change to its *.idx renaming, provide a thin wrapper for the old function as a static function in that file. If other callers end up needing the simpler version it could be moved back to "pack-write.c" and "pack.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-write.c')
-rw-r--r--pack-write.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/pack-write.c b/pack-write.c
index 5115791..32ebf0c 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -474,21 +474,28 @@ static void rename_tmp_packfile(struct strbuf *name_prefix, const char *source,
strbuf_setlen(name_prefix, name_prefix_len);
}
-void finish_tmp_packfile(struct strbuf *name_buffer,
+void rename_tmp_packfile_idx(struct strbuf *name_buffer,
+ char **idx_tmp_name)
+{
+ rename_tmp_packfile(name_buffer, *idx_tmp_name, "idx");
+}
+
+void stage_tmp_packfiles(struct strbuf *name_buffer,
const char *pack_tmp_name,
struct pack_idx_entry **written_list,
uint32_t nr_written,
struct pack_idx_option *pack_idx_opts,
- unsigned char hash[])
+ unsigned char hash[],
+ char **idx_tmp_name)
{
- const char *idx_tmp_name, *rev_tmp_name = NULL;
+ const char *rev_tmp_name = NULL;
if (adjust_shared_perm(pack_tmp_name))
die_errno("unable to make temporary pack file readable");
- idx_tmp_name = write_idx_file(NULL, written_list, nr_written,
- pack_idx_opts, hash);
- if (adjust_shared_perm(idx_tmp_name))
+ *idx_tmp_name = (char *)write_idx_file(NULL, written_list, nr_written,
+ pack_idx_opts, hash);
+ if (adjust_shared_perm(*idx_tmp_name))
die_errno("unable to make temporary index file readable");
rev_tmp_name = write_rev_file(NULL, written_list, nr_written, hash,
@@ -497,9 +504,6 @@ void finish_tmp_packfile(struct strbuf *name_buffer,
rename_tmp_packfile(name_buffer, pack_tmp_name, "pack");
if (rev_tmp_name)
rename_tmp_packfile(name_buffer, rev_tmp_name, "rev");
- rename_tmp_packfile(name_buffer, idx_tmp_name, "idx");
-
- free((void *)idx_tmp_name);
}
void write_promisor_file(const char *promisor_name, struct ref **sought, int nr_sought)