Re: [PATCHv2 1/2] submodule: port resolve_relative_url from shell to C

2016-01-22 Thread Stefan Beller
On Fri, Jan 22, 2016 at 11:03 AM, Johannes Sixt  wrote:
> Am 20.01.2016 um 03:03 schrieb Stefan Beller:
>> +static char *last_dir_separator(char *str)
>> +{
>> + char *p = str + strlen(str);
>> + while (p-- > str)
>> + if (is_dir_sep(*p))
>> + return p;
>> + return NULL;
>> +}
>> +
>
> I just noticed that we already have this function. Please squash in the
> following.

thanks for reviewing! squashed.

>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 1484b36..92d7d32 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -51,21 +51,12 @@ static int starts_with_dot_dot_slash(const char *str)
> return str[0] == '.' && str[1] == '.' && is_dir_sep(str[2]);
>  }
>
> -static char *last_dir_separator(char *str)
> -{
> -   char *p = str + strlen(str);
> -   while (p-- > str)
> -   if (is_dir_sep(*p))
> -   return p;
> -   return NULL;
> -}
> -
>  /*
>   * Returns 1 if it was the last chop before ':'.
>   */
>  static int chop_last_dir(char **remoteurl, int is_relative)
>  {
> -   char *rfind = last_dir_separator(*remoteurl);
> +   char *rfind = find_last_dir_sep(*remoteurl);
> if (rfind) {
> *rfind = '\0';
> return 0;
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 1/2] submodule: port resolve_relative_url from shell to C

2016-01-22 Thread Johannes Sixt
Am 20.01.2016 um 03:03 schrieb Stefan Beller:
> +static char *last_dir_separator(char *str)
> +{
> + char *p = str + strlen(str);
> + while (p-- > str)
> + if (is_dir_sep(*p))
> + return p;
> + return NULL;
> +}
> +

I just noticed that we already have this function. Please squash in the
following.

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 1484b36..92d7d32 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -51,21 +51,12 @@ static int starts_with_dot_dot_slash(const char *str)
return str[0] == '.' && str[1] == '.' && is_dir_sep(str[2]);
 }
 
-static char *last_dir_separator(char *str)
-{
-   char *p = str + strlen(str);
-   while (p-- > str)
-   if (is_dir_sep(*p))
-   return p;
-   return NULL;
-}
-
 /*
  * Returns 1 if it was the last chop before ':'.
  */
 static int chop_last_dir(char **remoteurl, int is_relative)
 {
-   char *rfind = last_dir_separator(*remoteurl);
+   char *rfind = find_last_dir_sep(*remoteurl);
if (rfind) {
*rfind = '\0';
return 0;

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html