All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
To: Junio C Hamano <gitster@pobox.com>
Cc: GIT Mailing-list <git@vger.kernel.org>, Jeff King <peff@peff.net>,
	Erik Faye-Lund <kusmabite@gmail.com>,
	Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCH 1/3] help.c: Fix detection of custom merge strategy on cygwin
Date: Sat, 18 Jun 2011 17:57:05 +0100	[thread overview]
Message-ID: <4DFCD8E1.3060102@ramsay1.demon.co.uk> (raw)
In-Reply-To: <7v1uyth0t9.fsf@alter.siamese.dyndns.org>

Junio C Hamano wrote:
> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
> 
>> -#ifdef WIN32
>> +#if defined(WIN32) || defined(__CYGWIN__)
>> +#if defined(__CYGWIN__)
>> +if ((st.st_mode & S_IXUSR) == 0)
>> +#endif
>>  {	/* cannot trust the executable bit, peek into the file instead */
>>  	char buf[3] = { 0 };
>>  	int n;
> 
> This looks somewhat ugly.

;-) Yeah, Johannes Sixt had a similar complaint last time ...

> I guess we could make the inner #if/#endif slightly more readable by
> letting the compiler do more work, like this:
> 
> 	#if defined(WIN32) || defined(__CYGWIN__)
>         if (!defined(__CYGWIN__) || !(st.st_mode & S_IXUSR)) {
              ^^^^^^^^^
This would have to be something like:

    #if defined(__CYGWIN__)
    #define IS_CYGWIN 1
    #else
    #define IS_CYGWIN 0
    #endif
    if (!IS_CYGWIN || !(st.st_mode & S_IXUSR)) {

no?
>         	...
> 	}
>         #endif
> 
> I dunno.

The first version of this patch looked like:

-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
+if ((st.st_mode & S_IXUSR) == 0)
 {	/* cannot trust the executable bit, peek into the file instead */

The idea being that the WIN32 builds (ie MinGW and MSVC) would never set
the executable bit, so this should only be false on cygwin when *not*
using the WIN32 l/stat implementation. So it should be safe ...

However, I got cold feet (and being lazy didn't want to test on MinGW and
MSVC) and decided on the more conservative approach.

Anyway, if you don't mind executing the "WIN32 code block" unnecessarily
on cygwin (I don't think it would be too expensive) then we could simply
reduce the patch to:

-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 {	/* cannot trust the executable bit, peek into the file instead */

(I've simply typed the above in my MUA, so not tested, obviously!)

This is exactly what Johannes proposed last year. :)

ATB,
Ramsay Jones

  reply	other threads:[~2011-06-18 19:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16 20:22 [PATCH 1/3] help.c: Fix detection of custom merge strategy on cygwin Ramsay Jones
2011-06-16 22:24 ` Junio C Hamano
2011-06-18 16:57   ` Ramsay Jones [this message]
2011-06-18 22:46     ` Mark Levedahl

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=4DFCD8E1.3060102@ramsay1.demon.co.uk \
    --to=ramsay@ramsay1.demon.co.uk \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=kusmabite@gmail.com \
    --cc=peff@peff.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.