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

Re: [PATCH v2 2/2] mingw: fix mingw_open_append to work with named pipes

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 10, 2018, 22:00 UTC
Message-ID
<xmqqbm95rp27.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<a309396f-bb33-477d-5d92-a98699f5a856@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
>>   +#define IS_SBS(ch) (((ch) == '/') || ((ch) == '\\'))

I think you already have mingw_is_dir_sep() and its shorter alias is_dir_sep() available to you.

Show 5 quoted lines
>> +/*
>> + * Does the pathname map to the local named pipe filesystem?
>> + * That is, does it have a "//./pipe/" prefix?
>> + */
>> +static int mingw_is_local_named_pipe_path(const char *filename)

There is no need to prefix mingw_ to this function that is file local static. Isn't is_local_named_pipe() descriptive and unique enough?

Show 10 quoted lines
>> +{
>> +	return (IS_SBS(filename[0]) &&
>> +		IS_SBS(filename[1]) &&
>> +		filename[2] == '.'  &&
>> +		IS_SBS(filename[3]) &&
>> +		!strncasecmp(filename+4, "pipe", 4) &&
>> +		IS_SBS(filename[8]) &&
>> +		filename[9]);
>> +}
>> +#undef IS_SBS

It is kind-of surprising that there hasn't been any existing need for a helper function that would allow us to write this function like so:

	static int is_local_named_pipe(const char *path)
	{
		return path_is_in_directory(path, "//./pipe/");
	}

Not a suggestion to add such a thing; as long as we know there is no other codepath that would benefit from having one, a generalization like that can and should wait.

Show 18 quoted lines
>>   int mingw_open (const char *filename, int oflags, ...)
>>   {
>>   	typedef int (*open_fn_t)(wchar_t const *wfilename, int oflags, ...);
>> @@ -387,7 +419,7 @@ int mingw_open (const char *filename, int oflags, ...)
>>   	if (filename && !strcmp(filename, "/dev/null"))
>>   		filename = "nul";
>>   -	if (oflags & O_APPEND)
>> +	if ((oflags & O_APPEND) && !mingw_is_local_named_pipe_path(filename))
>>   		open_fn = mingw_open_append;
>>   	else
>>   		open_fn = _wopen;
>
> This looks reasonable.
>
> I wonder which part of the code uses local named pipes. Is it
> downstream in Git for Windows or one of the topics in flight?
>
> -- Hannes
Previous: Jeff HostetlerNext: Jeff Hostetler
Message 17 of 21 in “Fixup for js/mingw-o-append”
  1. 0/2 Fixup for js/mingw-o-appendJeff Hostetler via GitGitGadget, Sep 7, 2018
  2. 1/2 t0051: test GIT_TRACE to a windows named pipeJeff Hostetler via GitGitGadget, Sep 7, 2018
  3. Sebastian SchuberthSep 9, 2018
  4. Jeff HostetlerSep 10, 2018
  5. 2/2 mingw: fix mingw_open_append to work with named pipesJeff Hostetler via GitGitGadget, Sep 7, 2018
  6. Johannes SixtSep 8, 2018
  7. Johannes SixtSep 8, 2018
  8. Jeff HostetlerSep 10, 2018
  9. Junio C HamanoSep 10, 2018
  10. Jeff HostetlerSep 10, 2018
  11. Jeff HostetlerSep 7, 2018
  12. 0/2 Fixup for js/mingw-o-appendJeff Hostetler via GitGitGadget, Sep 10, 2018
  13. 1/2 t0051: test GIT_TRACE to a windows named pipeJeff Hostetler via GitGitGadget, Sep 10, 2018
  14. 2/2 mingw: fix mingw_open_append to work with named pipesJeff Hostetler via GitGitGadget, Sep 10, 2018
  15. Johannes SixtSep 10, 2018
  16. Jeff HostetlerSep 10, 2018
  17. Junio C HamanoSep 10, 2018
  18. Jeff HostetlerSep 11, 2018
  19. 0/2 Fixup for js/mingw-o-appendJeff Hostetler via GitGitGadget, Sep 11, 2018
  20. 1/2 t0051: test GIT_TRACE to a windows named pipeJeff Hostetler via GitGitGadget, Sep 11, 2018
  21. 2/2 mingw: fix mingw_open_append to work with named pipesJeff Hostetler via GitGitGadget, Sep 11, 2018

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.