Re: [PATCH] mingw: allow hooks to be .exe files

2 messages, 2 authors, 2017-01-26 · open the first message on its own page

Re: [PATCH] mingw: allow hooks to be .exe files

From: Junio C Hamano <hidden>
Date: 2017-01-25 21:39:22

Johannes Schindelin [off-list ref] 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()).
quoted hunk
Signed-off-by: Johannes Schindelin <redacted>
---
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

Re: [PATCH] mingw: allow hooks to be .exe files

From: Johannes Schindelin <hidden>
Date: 2017-01-26 13:46:21

Hi Junio,

On Wed, 25 Jan 2017, Junio C Hamano wrote:
Johannes Schindelin [off-list ref] writes:
quoted
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"?
No, no longer .com. You have to jump through hoops in this century to
build .com files.
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?"
The answer is correct, the reasoning not. The reason why .exe is special:
it simply won't execute unless it has the .exe file extension. That is not
true for .py, .rb, etc

Ciao,
Johannes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help