Re: [PATCH v5 07/24] files-backend: add and use files_refname_path()
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Mar 9, 2017, 12:24 UTC
- Message-ID
- <984307d7-8e1f-fa7c-3d6d-6440954334c3@alum.mit.edu>
- In-Reply-To
- <20170222140450.30886-8-pclouds@gmail.com>
On 02/22/2017 03:04 PM, Nguyễn Thái Ngọc Duy wrote:
Show 29 quoted lines
> Keep repo-related path handling in one place. This will make it easier
> to add submodule/multiworktree support later.
>
> This automatically adds the "if submodule then use the submodule version
> of git_path" to other call sites too. But it does not mean those
> operations are sumodule-ready. Not yet.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> refs/files-backend.c | 45 +++++++++++++++++++++++++--------------------
> 1 file changed, 25 insertions(+), 20 deletions(-)
>
> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index 7b4ea4c56..72f4e1746 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> [...]
> @@ -1251,10 +1263,7 @@ static void read_loose_refs(const char *dirname, struct ref_dir *dir)
> size_t path_baselen;
> int err = 0;
>
> - if (refs->submodule)
> - err = strbuf_git_path_submodule(&path, refs->submodule, "%s", dirname);
> - else
> - strbuf_git_path(&path, "%s", dirname);
> + files_refname_path(refs, &path, dirname);
> path_baselen = path.len;
>
> if (err) {I just noticed another thing. After this change, `err` is never set, so the `if (err)` block (and `err` itself) can be deleted.
> [...]
Michael