Re: [PATCH 03/28] packed_ref_store: move `packed_refs_path` here
- From
Stefan Beller <sbeller@google.com>
- Date
- Jun 16, 2017, 05:30 UTC
- Message-ID
- <CAGZ79kYOtGc5p2bU5-oWCq60N87v4CbcdYjAurzirjRsyVdEwQ@mail.gmail.com>
- In-Reply-To
- <2aa91c07ef7f0f9c679aab8898341520eda76016.1497534157.git.mhagger@alum.mit.edu>
On Thu, Jun 15, 2017 at 7:47 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote:
Show 37 quoted lines
> Move `packed_refs_path` from `files_ref_store` to `packed_ref_store`,
> and rename it to `path` since its meaning is clear from its new
> context.
>
> Inline `files_packed_refs_path()`.
>
> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
> ---
> refs/files-backend.c | 25 ++++++++++++-------------
> 1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index 2efb71cee9..c4b8e2f63b 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -54,6 +54,9 @@ struct packed_ref_cache {
> struct packed_ref_store {
> unsigned int store_flags;
>
> + /* The path of the "packed-refs" file: */
> + char *path;
> +
> /*
> * A cache of the values read from the `packed-refs` file, if
> * it might still be current; otherwise, NULL.
> @@ -61,11 +64,13 @@ struct packed_ref_store {
> struct packed_ref_cache *cache;
> };
>
> -static struct packed_ref_store *packed_ref_store_create(unsigned int store_flags)
> +static struct packed_ref_store *packed_ref_store_create(
> + const char *path, unsigned int store_flags)
> {
> struct packed_ref_store *refs = xcalloc(1, sizeof(*refs));
>
> refs->store_flags = store_flags;
> + refs->path = xstrdup(path);mental note: the destructor (if introduced later) has to free the path.