git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: jeffhost@microsoft.com,
	Jeff Hostetler via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH v2 2/2] mingw: fix mingw_open_append to work with named pipes
Date: Mon, 10 Sep 2018 15:00:00 -0700	[thread overview]
Message-ID: <xmqqbm95rp27.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <a309396f-bb33-477d-5d92-a98699f5a856@kdbg.org> (Johannes Sixt's message of "Mon, 10 Sep 2018 21:45:05 +0200")

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.

>> +/*
>> + * 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?

>> +{
>> +	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.

>>   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

  parent reply	other threads:[~2018-09-10 22:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-07 18:19 [PATCH 0/2] Fixup for js/mingw-o-append Jeff Hostetler via GitGitGadget
2018-09-07 18:19 ` [PATCH 1/2] t0051: test GIT_TRACE to a windows named pipe Jeff Hostetler via GitGitGadget
2018-09-09  7:28   ` Sebastian Schuberth
2018-09-10 13:21     ` Jeff Hostetler
2018-09-07 18:19 ` [PATCH 2/2] mingw: fix mingw_open_append to work with named pipes Jeff Hostetler via GitGitGadget
2018-09-08  9:26   ` Johannes Sixt
2018-09-08 18:31     ` Johannes Sixt
2018-09-10 15:44       ` Jeff Hostetler
2018-09-10 16:42         ` Junio C Hamano
2018-09-10 16:55           ` Jeff Hostetler
2018-09-07 18:36 ` [PATCH 0/2] Fixup for js/mingw-o-append Jeff Hostetler
2018-09-10 17:05 ` [PATCH v2 " Jeff Hostetler via GitGitGadget
2018-09-10 17:05   ` [PATCH v2 1/2] t0051: test GIT_TRACE to a windows named pipe Jeff Hostetler via GitGitGadget
2018-09-10 17:05   ` [PATCH v2 2/2] mingw: fix mingw_open_append to work with named pipes Jeff Hostetler via GitGitGadget
2018-09-10 19:45     ` Johannes Sixt
2018-09-10 20:07       ` Jeff Hostetler
2018-09-10 22:00       ` Junio C Hamano [this message]
2018-09-11 14:25         ` Jeff Hostetler
2018-09-11 20:05   ` [PATCH v3 0/2] Fixup for js/mingw-o-append Jeff Hostetler via GitGitGadget
2018-09-11 20:06     ` [PATCH v3 1/2] t0051: test GIT_TRACE to a windows named pipe Jeff Hostetler via GitGitGadget
2018-09-11 20:06     ` [PATCH v3 2/2] mingw: fix mingw_open_append to work with named pipes Jeff Hostetler via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqbm95rp27.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=j6t@kdbg.org \
    --cc=jeffhost@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).