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

Re: [PATCH v2] Fix safe_create_leading_directories() for Windows

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 2, 2014, 22:12 UTC
Message-ID
<xmqqsit6nid3.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqzjnenjcd.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 37 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> This has a bit of conflict with another topic in flight; I think I
>> resolved it correctly, but please double check.  The following is
>> how it would apply on top of 'pu'.
>>
>>  sha1_file.c | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/sha1_file.c b/sha1_file.c
>> index 131ca97..9e686eb 100644
>> --- a/sha1_file.c
>> +++ b/sha1_file.c
>> @@ -113,11 +113,12 @@ int safe_create_leading_directories(char *path)
>>  
>>  	while (!retval && next_component) {
>>  		struct stat st;
>> -		char *slash = strchr(next_component, '/');
>> -
>> -		if (!slash)
>> +		char *slash = next_component;
>> +		while (!is_dir_sep(*slash))
>
> Gaah; we need to check for the end of string here, i.e.
>
> 		while (*slash && !is_dir_sep(*slash))
>
> will be what I'll queue on 'pu' for today.
>
>> +			++slash;
>> +		if (!*slash)
>>  			return 0;
>> -		while (*(slash + 1) == '/')
>> +		while (is_dir_sep(*(slash + 1)))
>>  			slash++;
>>  		next_component = slash + 1;
>>  		if (!*next_component)

Another thing I noticed (but I won't fix it up myself today, as I am deep into today's integration cycle already) is that we temporarily replace the slash with NUL and then restore them before we return, but the restoration is done with the slash. If we were to go in the direction of this patch, you may want to update that one to use whatever dir-sep was used in the input string.

Previous: Junio C HamanoNext: Junio C Hamano
Message 17 of 22 in “Fix safe_create_leading_directories() for Windows”
  1. Fix safe_create_leading_directories() for WindowsSebastian Schuberth, Jan 2, 2014
  2. Johannes SchindelinJan 2, 2014
  3. Sebastian SchuberthJan 2, 2014
  4. John KeepingJan 2, 2014
  5. Sebastian SchuberthJan 2, 2014
  6. Johannes SchindelinJan 2, 2014
  7. Erik Faye-LundJan 7, 2014
  8. Johannes SchindelinJan 7, 2014
  9. Sebastian SchuberthJan 7, 2014
  10. Junio C HamanoJan 2, 2014
  11. Johannes SchindelinJan 2, 2014
  12. Sebastian SchuberthJan 2, 2014
  13. Fix safe_create_leading_directories() for WindowsSebastian Schuberth, Jan 2, 2014
  14. Johannes SchindelinJan 2, 2014
  15. Junio C HamanoJan 2, 2014
  16. Junio C HamanoJan 2, 2014
  17. Junio C HamanoJan 2, 2014
  18. Junio C HamanoJan 2, 2014
  19. Johannes SchindelinJan 2, 2014
  20. Sebastian SchuberthJan 19, 2014
  21. Sebastian SchuberthJan 19, 2014
  22. Junio C HamanoJan 21, 2014

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.