Re: [PATCH 03/12] pack-write: stop depending on `the_repository` and `the_hash_algo`
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Mar 4, 2025, 18:46 UTC
- Message-ID
- <hqhlqyonijhjovsop3s3bqv2hjkfp2pde6h4r4jzlcrcreygvf@k53cld26eqs3>
- In-Reply-To
- <20250303-b4-pks-objects-without-the-repository-v1-3-c5dd43f2476e@pks.im>
On 25/03/03 09:47AM, Patrick Steinhardt wrote:
Show 6 quoted lines
> There are a couple of functions in "pack-write.c" that implicitly depend > on `the_repository` or `the_hash_algo`. Remove this dependency by > injecting the repository via a parameter and adapt callers accordingly. > > Signed-off-by: Patrick Steinhardt <ps@pks.im> > ---
[snip]
Show 26 quoted lines
> diff --git a/pack.h b/pack.h > index 9f1194ac13d..5d4393eaffe 100644 > --- a/pack.h > +++ b/pack.h > @@ -87,7 +87,7 @@ struct progress; > /* Note, the data argument could be NULL if object type is blob */ > typedef int (*verify_fn)(const struct object_id *, enum object_type, unsigned long, void*, int*); > > -const char *write_idx_file(const struct git_hash_algo *hash_algo, > +const char *write_idx_file(struct repository *repo, > const char *index_name, > struct pack_idx_entry **objects, > int nr_objects, > @@ -106,13 +106,13 @@ struct ref; > > void write_promisor_file(const char *promisor_name, struct ref **sought, int nr_sought); > > -char *write_rev_file(const struct git_hash_algo *hash_algo, > +char *write_rev_file(struct repository *repo, > const char *rev_name, > struct pack_idx_entry **objects, > uint32_t nr_objects, > const unsigned char *hash, > unsigned flags); > -char *write_rev_file_order(const struct git_hash_algo *hash_algo, > +char *write_rev_file_order(struct repository *repo,
These couple of functions were already injecting git_hash_algo, but still depended on the_repostiory. By instead injecting repository directly, we get both.
Makes sense.
Show 20 quoted lines
> const char *rev_name, > uint32_t *pack_order, > uint32_t nr_objects, > @@ -134,8 +134,9 @@ int read_pack_header(int fd, struct pack_header *); > > struct packing_data; > > -struct hashfile *create_tmp_packfile(char **pack_tmp_name); > -void stage_tmp_packfiles(const struct git_hash_algo *hash_algo, > +struct hashfile *create_tmp_packfile(struct repository *repo, > + char **pack_tmp_name); > +void stage_tmp_packfiles(struct repository *repo, > struct strbuf *name_buffer, > const char *pack_tmp_name, > struct pack_idx_entry **written_list, > > -- > 2.49.0.rc0.375.gae4b89d849.dirty > >