Re: [PATCH v5 04/17] odb: introduce parent pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 25/06/05 08:46AM, Patrick Steinhardt wrote:
> In subsequent commits we'll get rid of our use of `the_repository` in
> "odb.c" in favor of explicitly passing in a `struct object_database` or
> a `struct odb_source`. In some cases though we'll need access to the
> repository, for example to read a config value from it, but we don't
> have a way to access the repository owning a specific object database.
> 
> Introduce parent pointers for `struct object_database` to its owning
> repository as well as for `struct odb_source` to its owning object
> database, which will allow us to adapt those use cases.

Ok so in this patch we are introducing the parent pointers and setting
them up, but not actually using them for anything yet.

> Note that this change requires us to pass through the object database to
> `link_alt_odb_entry()` so that we can set up the parent pointers for any
> source there. The callchain is adapted to pass through the object
> database accordingly.

Ok IIUC, for `link_alt_odb_entry()`, the reason we to pass `struct
object_database` instead of `struct odb_source` is because the sources
need to be set up with the pointer to the parent odb. That makes sense.

> Signed-off-by: Patrick Steinhardt <ps@xxxxxx>
> ---
>  odb.c        | 47 +++++++++++++++++++++++++++--------------------
>  odb.h        |  8 +++++++-
>  repository.c |  3 ++-
>  3 files changed, 36 insertions(+), 22 deletions(-)
> 
> diff --git a/odb.c b/odb.c
> index d1025ac182d..afb16f4c693 100644
> --- a/odb.c
> +++ b/odb.c
> @@ -135,11 +135,15 @@ static int alt_odb_usable(struct object_database *o,
>   * of the object ID, an extra slash for the first level indirection, and
>   * the terminating NUL.
>   */
> -static void read_info_alternates(struct repository *r,
> +static void read_info_alternates(struct object_database *odb,
>  				 const char *relative_base,
>  				 int depth);
> -static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,
> -	const char *relative_base, int depth, const char *normalized_objdir)
> +
> +static int link_alt_odb_entry(struct object_database *odb,
> +			      const struct strbuf *entry,
> +			      const char *relative_base,
> +			      int depth,
> +			      const char *normalized_objdir)
>  {
>  	struct odb_source *alternate;
>  	struct strbuf pathbuf = STRBUF_INIT;
> @@ -167,22 +171,23 @@ static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry,
>  	while (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/')
>  		strbuf_setlen(&pathbuf, pathbuf.len - 1);
>  
> -	if (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos))
> +	if (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos))
>  		goto error;
>  
>  	CALLOC_ARRAY(alternate, 1);
> -	/* pathbuf.buf is already in r->objects->source_by_path */
> +	alternate->odb = odb;
> +	/* pathbuf.buf is already in r->objects->alternate_by_path */

Should this comment instead say "odb->source_by_path"?

The remaining restructuring in this patch looks good.

-Justin




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux