Re: [PATCH v4 16/16] refs.c: reindent get_submodule_ref_store()
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Sep 9, 2017, 06:41 UTC
- Message-ID
- <a445a47f-9fe9-1c56-8e14-eb5aafbdbb0f@alum.mit.edu>
- In-Reply-To
- <20170823123704.16518-17-pclouds@gmail.com>
On 08/23/2017 02:37 PM, Nguyễn Thái Ngọc Duy wrote:
Show 32 quoted lines
> With the new "if (!submodule) return NULL;" code added in the previous
> commit, we don't need to check if submodule is not NULL anymore.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> refs.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/refs.c b/refs.c
> index a0c5078901..206af61d62 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -1590,13 +1590,11 @@ struct ref_store *get_submodule_ref_store(const char *submodule)
> if (!submodule)
> return NULL;
>
> - if (submodule) {
> - len = strlen(submodule);
> - while (len && is_dir_sep(submodule[len - 1]))
> - len--;
> - if (!len)
> - return NULL;
> - }
> + len = strlen(submodule);
> + while (len && is_dir_sep(submodule[len - 1]))
> + len--;
> + if (!len)
> + return NULL;
>
> if (submodule[len])
> /* We need to strip off one or more trailing slashes */
> Now I'm confused. Is it still allowed to call `get_submodule_ref_store(NULL)`? If not, then the previous commit should probably do
if (!submdule) BUG(...);
Either way, it seems like it would be natural to combine this commit with the previous one.
Michael