Re: [PATCH v2 09/13] submodule--helper: refactor get_submodule_displaypath()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 28 2022, Glen Choo wrote:

> From: Atharva Raykar <raykar.ath@xxxxxxxxx>
>
> We create a function called `do_get_submodule_displaypath()` that
> generates the display path required by several submodule functions, and
> takes a custom superprefix parameter, instead of reading it from the
> environment.
>
> We then redefine the existing `get_submodule_displaypath()` function
> as a call to this new function, where the superprefix is obtained from
> the environment.
>
> Mentored-by: Christian Couder <christian.couder@xxxxxxxxx>
> Mentored-by: Shourya Shukla <periperidip@xxxxxxxxx>
> Signed-off-by: Atharva Raykar <raykar.ath@xxxxxxxxx>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
> ---
>  builtin/submodule--helper.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 99341fb343..11afdeea8a 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -247,11 +247,8 @@ static int resolve_relative_url_test(int argc, const char **argv, const char *pr
>  	return 0;
>  }
>  
> -/* the result should be freed by the caller. */

nit: I think it's better to retain this comment here...

> -static char *get_submodule_displaypath(const char *path, const char *prefix)
> +static char *do_get_submodule_displaypath(const char *path, const char *prefix, const char *super_prefix)
>  {
> -	const char *super_prefix = get_super_prefix();
> -
>  	if (prefix && super_prefix) {
>  		BUG("cannot have prefix '%s' and superprefix '%s'",
>  		    prefix, super_prefix);
> @@ -267,6 +264,13 @@ static char *get_submodule_displaypath(const char *path, const char *prefix)
>  	}
>  }
>  
> +/* the result should be freed by the caller. */

..than have it here, where we don't do the xstrfmt() but just call this wrapper.:

> +static char *get_submodule_displaypath(const char *path, const char *prefix)
> +{
> +	const char *super_prefix = get_super_prefix();
> +	return do_get_submodule_displaypath(path, prefix, super_prefix);
> +}
> +
>  static char *compute_rev_name(const char *sub_path, const char* object_id)
>  {
>  	struct strbuf sb = STRBUF_INIT;





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux