git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Sixt <j6t@kdbg.org>
Date
Jan 22, 2016, 19:03 UTC
Message-ID
<56A27D1F.60007@kdbg.org>
In-Reply-To
<1453255396-31942-2-git-send-email-sbeller@google.com>
Am 20.01.2016 um 03:03 schrieb Stefan Beller:
Show 9 quoted lines
> +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;
Previous: Stefan BellerNext: Stefan Beller
Message 7 of 16 in “Port `git submodule init` from shell to C”
  1. 0/2 Port `git submodule init` from shell to CStefan Beller, Jan 15, 2016
  2. 1/2 submodule: Port resolve_relative_url from shell to CStefan Beller, Jan 15, 2016
  3. 2/2 submodule: Port init from shell to CStefan Beller, Jan 15, 2016
  4. Junio C HamanoJan 19, 2016
  5. 0/2 Port `git submodule init` from shell to CStefan Beller, Jan 20, 2016
  6. 1/2 submodule: port resolve_relative_url from shell to CStefan Beller, Jan 20, 2016
  7. Johannes SixtJan 22, 2016
  8. Stefan BellerJan 22, 2016
  9. 2/2 submodule: port init from shell to CStefan Beller, Jan 20, 2016
  10. 2/2 submodule: port init from shell to CStefan Beller, Jan 20, 2016
  11. Junio C HamanoJan 20, 2016
  12. Stefan BellerJan 20, 2016
  13. Junio C HamanoJan 20, 2016
  14. 2/2 submodule: port init from shell to CStefan Beller, Jan 21, 2016
  15. Junio C HamanoJan 22, 2016
  16. Stefan BellerJan 22, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.