diff mbox series

[3/8] tmp-objdir: expose function to retrieve path

Message ID a5ca94e3f4df2abb38880385310e5cb02d7b5daa.1621451532.git.ps@pks.im (mailing list archive)
State New, archived
Headers show
Series Speed up connectivity checks via quarantine dir | expand

Commit Message

Patrick Steinhardt May 19, 2021, 7:13 p.m. UTC
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.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 tmp-objdir.c | 7 +++++++
 tmp-objdir.h | 5 +++++
 2 files changed, 12 insertions(+)

Comments

Elijah Newren May 20, 2021, 12:16 a.m. UTC | #1
On Wed, May 19, 2021 at 1:22 PM Patrick Steinhardt <ps@pks.im> wrote:
>
> 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.  :-)

> 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.1

Looks good to me.
diff mbox series

Patch

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 */