git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] mingw: allow hooks to be .exe files
Date: Wed, 25 Jan 2017 13:39:14 -0800	[thread overview]
Message-ID: <xmqq37g6akfx.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <dc388b2df3baee83972f007cd77a57410553a411.1485362812.git.johannes.schindelin@gmx.de> (Johannes Schindelin's message of "Wed, 25 Jan 2017 17:58:42 +0100 (CET)")

Johannes Schindelin <johannes.schindelin@gmx.de> writes:

> This change is necessary to allow the files in .git/hooks/ to optionally
> have the file extension `.exe` on Windows, as the file names are
> hardcoded otherwise.

Hmph.  There is no longer ".com"?

I briefly wondered if hooks/post-receive.{py,rb,...} would be good
things to support, but I do not think we want to go there, primarily
because we do not want to deal with "what happens when there are
many?"

As Peff pointed out while I was typing this message, ".exe" would be
better spelled as STRIP_EXTENSION, I think.  The resulting code
would read naturally when you read the macro not as "please do strip
extensions" boolean, but as "this extension is to be stripped"
string, which is how it is used in the other site the macro is used
(namely, strip_extension() called by handle_builtin()).

> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> ---
> Published-As: https://github.com/dscho/git/releases/tag/exe-as-hook-v1
> Fetch-It-Via: git fetch https://github.com/dscho/git exe-as-hook-v1
>
>  run-command.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/run-command.c b/run-command.c
> index 73bfba7ef9..45229ef052 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -871,8 +871,14 @@ const char *find_hook(const char *name)
>  
>  	strbuf_reset(&path);
>  	strbuf_git_path(&path, "hooks/%s", name);
> -	if (access(path.buf, X_OK) < 0)
> +	if (access(path.buf, X_OK) < 0) {
> +#ifdef STRIP_EXTENSION
> +		strbuf_addstr(&path, ".exe");
> +		if (access(path.buf, X_OK) >= 0)
> +			return path.buf;
> +#endif
>  		return NULL;
> +	}
>  	return path.buf;
>  }
>  
>
> base-commit: 4e59582ff70d299f5a88449891e78d15b4b3fabe

  parent reply	other threads:[~2017-01-25 21:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-25 16:58 [PATCH] mingw: allow hooks to be .exe files Johannes Schindelin
2017-01-25 21:15 ` Jeff King
2017-01-25 21:39   ` Junio C Hamano
2017-01-26 12:21   ` Johannes Schindelin
2017-01-26 18:44     ` Junio C Hamano
2017-01-27 10:29       ` Johannes Schindelin
2017-01-27 18:24         ` Stefan Beller
2017-01-30 12:29           ` Johannes Schindelin
2017-01-25 21:39 ` Junio C Hamano [this message]
2017-01-26 13:45   ` Johannes Schindelin
2017-01-26 12:21 ` [PATCH v2] " Johannes Schindelin
2017-01-30 12:28   ` [PATCH v3] " Johannes Schindelin
2017-01-30 16:51     ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqq37g6akfx.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).