Re: [PATCH 3/8] tmp-objdir: expose function to retrieve path
- From
Elijah Newren <newren@gmail.com>
- Date
- May 20, 2021, 00:16 UTC
- Message-ID
- <CABPp-BGXH1oSVn9jS-CC2P0snUzgo5CN=nPbXtWrOm0Ugjz1Hg@mail.gmail.com>
- In-Reply-To
- <a5ca94e3f4df2abb38880385310e5cb02d7b5daa.1621451532.git.ps@pks.im>
On Wed, May 19, 2021 at 1:22 PM Patrick Steinhardt <ps@pks.im> wrote:
Show 8 quoted lines
> > It's currently impossible to tell the path of a temporary object > directory for outside users of `struct tmp_objdir`. We'll soon need that > information though so that we can reuse information from the quarantine > environment in git-receive-pack(1). > > Provide a new function `tmp_objdir_path()` which returns the path of a > temporary object directory to prepare for this.
Oh, sweet, someone else wants this too. I have a local patch introducing the same function, which I needed for --remerge-diff. I hadn't submitted the patch yet, and if yours is accepted then I won't need to. :-)
Show 40 quoted lines
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> tmp-objdir.c | 7 +++++++
> tmp-objdir.h | 5 +++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/tmp-objdir.c b/tmp-objdir.c
> index b8d880e362..6056917c63 100644
> --- a/tmp-objdir.c
> +++ b/tmp-objdir.c
> @@ -288,6 +288,13 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)
> return t->env.v;
> }
>
> +const char *tmp_objdir_path(const struct tmp_objdir *t)
> +{
> + if (!t)
> + return NULL;
> + return t->path.buf;
> +}
> +
> void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)
> {
> add_to_alternates_memory(t->path.buf);
> diff --git a/tmp-objdir.h b/tmp-objdir.h
> index b1e45b4c75..da3ccb98bc 100644
> --- a/tmp-objdir.h
> +++ b/tmp-objdir.h
> @@ -51,4 +51,9 @@ int tmp_objdir_destroy(struct tmp_objdir *);
> */
> void tmp_objdir_add_as_alternate(const struct tmp_objdir *);
>
> +/*
> + * Return the path of the temporary object directory.
> + */
> +const char *tmp_objdir_path(const struct tmp_objdir *t);
> +
> #endif /* TMP_OBJDIR_H */
> --
> 2.31.1Looks good to me.