* [PATCH] mingw: allow hooks to be .exe files
@ 2017-01-25 16:58 Johannes Schindelin
2017-01-25 21:15 ` Jeff King
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Johannes Schindelin @ 2017-01-25 16:58 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
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.
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
--
2.11.1.windows.prerelease.2.3.g7f3eb74
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] mingw: allow hooks to be .exe files
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-25 21:39 ` Junio C Hamano
2017-01-26 12:21 ` [PATCH v2] " Johannes Schindelin
2 siblings, 2 replies; 13+ messages in thread
From: Jeff King @ 2017-01-25 21:15 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, Junio C Hamano
On Wed, Jan 25, 2017 at 05:58:42PM +0100, Johannes Schindelin wrote:
> 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.
Make sense as a goal.
> - if (access(path.buf, X_OK) < 0)
> + if (access(path.buf, X_OK) < 0) {
> +#ifdef STRIP_EXTENSION
> + strbuf_addstr(&path, ".exe");
I think STRIP_EXTENSION is a string. Should this line be:
strbuf_addstr(&path, STRIP_EXTENSION);
?
-Peff
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] mingw: allow hooks to be .exe files
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 13:45 ` Johannes Schindelin
2017-01-26 12:21 ` [PATCH v2] " Johannes Schindelin
2 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2017-01-25 21:39 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] mingw: allow hooks to be .exe files
2017-01-25 21:15 ` Jeff King
@ 2017-01-25 21:39 ` Junio C Hamano
2017-01-26 12:21 ` Johannes Schindelin
1 sibling, 0 replies; 13+ messages in thread
From: Junio C Hamano @ 2017-01-25 21:39 UTC (permalink / raw)
To: Jeff King; +Cc: Johannes Schindelin, git
Jeff King <peff@peff.net> writes:
> On Wed, Jan 25, 2017 at 05:58:42PM +0100, Johannes Schindelin wrote:
>
>> 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.
>
> Make sense as a goal.
>
>> - if (access(path.buf, X_OK) < 0)
>> + if (access(path.buf, X_OK) < 0) {
>> +#ifdef STRIP_EXTENSION
>> + strbuf_addstr(&path, ".exe");
>
> I think STRIP_EXTENSION is a string. Should this line be:
>
> strbuf_addstr(&path, STRIP_EXTENSION);
>
> ?
Yup, I think that is more in line with how git.c (the other user of
the macro) uses it.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] mingw: allow hooks to be .exe files
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
1 sibling, 1 reply; 13+ messages in thread
From: Johannes Schindelin @ 2017-01-26 12:21 UTC (permalink / raw)
To: Jeff King; +Cc: git, Junio C Hamano
Hi Peff,
On Wed, 25 Jan 2017, Jeff King wrote:
> On Wed, Jan 25, 2017 at 05:58:42PM +0100, Johannes Schindelin wrote:
>
> > - if (access(path.buf, X_OK) < 0)
> > + if (access(path.buf, X_OK) < 0) {
> > +#ifdef STRIP_EXTENSION
> > + strbuf_addstr(&path, ".exe");
>
> I think STRIP_EXTENSION is a string. Should this line be:
>
> strbuf_addstr(&path, STRIP_EXTENSION);
Yep.
v2 coming,
Johannes
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2] mingw: allow hooks to be .exe files
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-30 12:28 ` [PATCH v3] " Johannes Schindelin
2 siblings, 1 reply; 13+ messages in thread
From: Johannes Schindelin @ 2017-01-26 12:21 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Jeff King
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.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
Published-As: https://github.com/dscho/git/releases/tag/exe-as-hook-v2
Fetch-It-Via: git fetch https://github.com/dscho/git exe-as-hook-v2
Interdiff vs v1:
diff --git a/run-command.c b/run-command.c
index 45229ef052..5227f78aea 100644
--- a/run-command.c
+++ b/run-command.c
@@ -873,7 +873,7 @@ const char *find_hook(const char *name)
strbuf_git_path(&path, "hooks/%s", name);
if (access(path.buf, X_OK) < 0) {
#ifdef STRIP_EXTENSION
- strbuf_addstr(&path, ".exe");
+ strbuf_addstr(&path, STRIP_EXTENSION);
if (access(path.buf, X_OK) >= 0)
return path.buf;
#endif
run-command.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/run-command.c b/run-command.c
index 73bfba7ef9..5227f78aea 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, STRIP_EXTENSION);
+ if (access(path.buf, X_OK) >= 0)
+ return path.buf;
+#endif
return NULL;
+ }
return path.buf;
}
base-commit: 4e59582ff70d299f5a88449891e78d15b4b3fabe
--
2.11.1.windows.prerelease.2.9.g3014b57
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] mingw: allow hooks to be .exe files
2017-01-25 21:39 ` Junio C Hamano
@ 2017-01-26 13:45 ` Johannes Schindelin
0 siblings, 0 replies; 13+ messages in thread
From: Johannes Schindelin @ 2017-01-26 13:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Hi Junio,
On Wed, 25 Jan 2017, Junio C Hamano wrote:
> 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"?
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] mingw: allow hooks to be .exe files
2017-01-26 12:21 ` Johannes Schindelin
@ 2017-01-26 18:44 ` Junio C Hamano
2017-01-27 10:29 ` Johannes Schindelin
0 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2017-01-26 18:44 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Jeff King, git
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Hi Peff,
>
> On Wed, 25 Jan 2017, Jeff King wrote:
>
>> On Wed, Jan 25, 2017 at 05:58:42PM +0100, Johannes Schindelin wrote:
>>
>> > - if (access(path.buf, X_OK) < 0)
>> > + if (access(path.buf, X_OK) < 0) {
>> > +#ifdef STRIP_EXTENSION
>> > + strbuf_addstr(&path, ".exe");
>>
>> I think STRIP_EXTENSION is a string. Should this line be:
>>
>> strbuf_addstr(&path, STRIP_EXTENSION);
>
> Yep.
>
> v2 coming,
> Johannes
I think I've already tweaked it out when I queued the original one.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] mingw: allow hooks to be .exe files
2017-01-26 18:44 ` Junio C Hamano
@ 2017-01-27 10:29 ` Johannes Schindelin
2017-01-27 18:24 ` Stefan Beller
0 siblings, 1 reply; 13+ messages in thread
From: Johannes Schindelin @ 2017-01-27 10:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jeff King, git
Hi Junio,
On Thu, 26 Jan 2017, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > On Wed, 25 Jan 2017, Jeff King wrote:
> >
> >> On Wed, Jan 25, 2017 at 05:58:42PM +0100, Johannes Schindelin wrote:
> >>
> >> > - if (access(path.buf, X_OK) < 0)
> >> > + if (access(path.buf, X_OK) < 0) {
> >> > +#ifdef STRIP_EXTENSION
> >> > + strbuf_addstr(&path, ".exe");
> >>
> >> I think STRIP_EXTENSION is a string. Should this line be:
> >>
> >> strbuf_addstr(&path, STRIP_EXTENSION);
> >
> > Yep.
> >
> > v2 coming,
> > Johannes
>
> I think I've already tweaked it out when I queued the original one.
After digging, I found your SQUASH commit. I had not known about that.
In any case, I much rather prefer to have the final version of any patch
or patch series I contribute to be identical between what you commit and
what I sent to the mailing list. We do disagree from time to time, and I
would like to have the opportunity of reviewing how you tweak my changes.
Ciao,
Johannes
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] mingw: allow hooks to be .exe files
2017-01-27 10:29 ` Johannes Schindelin
@ 2017-01-27 18:24 ` Stefan Beller
2017-01-30 12:29 ` Johannes Schindelin
0 siblings, 1 reply; 13+ messages in thread
From: Stefan Beller @ 2017-01-27 18:24 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Junio C Hamano, Jeff King, git
On Fri, Jan 27, 2017 at 2:29 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Hi Junio,
>
> On Thu, 26 Jan 2017, Junio C Hamano wrote:
>
>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>>
>> > On Wed, 25 Jan 2017, Jeff King wrote:
>> >
>> >> On Wed, Jan 25, 2017 at 05:58:42PM +0100, Johannes Schindelin wrote:
>> >>
>> >> > - if (access(path.buf, X_OK) < 0)
>> >> > + if (access(path.buf, X_OK) < 0) {
>> >> > +#ifdef STRIP_EXTENSION
>> >> > + strbuf_addstr(&path, ".exe");
>> >>
>> >> I think STRIP_EXTENSION is a string. Should this line be:
>> >>
>> >> strbuf_addstr(&path, STRIP_EXTENSION);
>> >
>> > Yep.
>> >
>> > v2 coming,
>> > Johannes
>>
>> I think I've already tweaked it out when I queued the original one.
>
> After digging, I found your SQUASH commit. I had not known about that.
>
> In any case, I much rather prefer to have the final version of any patch
> or patch series I contribute to be identical between what you commit and
> what I sent to the mailing list. We do disagree from time to time, and I
> would like to have the opportunity of reviewing how you tweak my changes.
>
> Ciao,
> Johannes
I saw the queued up commit and that lead me to this thread here.
The commit message, while technically correct, seems a bit off. This is because
the commit message only talks about .exe extensions, but the change in code
doesn't even have the string "exe" mentioned once.
With this discussion here, it is easy for me to connect the dots, but
it would be nice
to have the full picture in the commit message. This is what I would write:
mingw: allow hooks to be .exe files
Executable files in Windows need to have the extension '.exe', otherwise
they do not work. Extend the hooks to not just look at the hard coded names,
but also at the extended names via the custom STRIP_EXTENSION, which
is defined as '.exe' in Windows.
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3] mingw: allow hooks to be .exe files
2017-01-26 12:21 ` [PATCH v2] " Johannes Schindelin
@ 2017-01-30 12:28 ` Johannes Schindelin
2017-01-30 16:51 ` Junio C Hamano
0 siblings, 1 reply; 13+ messages in thread
From: Johannes Schindelin @ 2017-01-30 12:28 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Jeff King, Stefan Beller
Executable files in Windows need to have the extension '.exe', otherwise
they do not work. Extend the hooks to not just look at the hard coded
names, but also at the names extended by the custom STRIP_EXTENSION,
which is defined as '.exe' in Windows.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Published-As: https://github.com/dscho/git/releases/tag/exe-as-hook-v3
Fetch-It-Via: git fetch https://github.com/dscho/git exe-as-hook-v3
run-command.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/run-command.c b/run-command.c
index 73bfba7ef9..5227f78aea 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, STRIP_EXTENSION);
+ if (access(path.buf, X_OK) >= 0)
+ return path.buf;
+#endif
return NULL;
+ }
return path.buf;
}
base-commit: 4e59582ff70d299f5a88449891e78d15b4b3fabe
--
2.11.1.windows.prerelease.2.9.g3014b57
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] mingw: allow hooks to be .exe files
2017-01-27 18:24 ` Stefan Beller
@ 2017-01-30 12:29 ` Johannes Schindelin
0 siblings, 0 replies; 13+ messages in thread
From: Johannes Schindelin @ 2017-01-30 12:29 UTC (permalink / raw)
To: Stefan Beller; +Cc: Junio C Hamano, Jeff King, git
Hi Stefan,
On Fri, 27 Jan 2017, Stefan Beller wrote:
> On Fri, Jan 27, 2017 at 2:29 AM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> > Hi Junio,
> >
> > On Thu, 26 Jan 2017, Junio C Hamano wrote:
> >
> >> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> >>
> >> > On Wed, 25 Jan 2017, Jeff King wrote:
> >> >
> >> > v2 coming,
>
> The commit message, while technically correct, seems a bit off. This is
> because the commit message only talks about .exe extensions, but the
> change in code doesn't even have the string "exe" mentioned once.
>
> With this discussion here, it is easy for me to connect the dots, but it
> would be nice to have the full picture in the commit message.
I just sent out v3, using a slightly tweaked version of the commit message
you proposed.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3] mingw: allow hooks to be .exe files
2017-01-30 12:28 ` [PATCH v3] " Johannes Schindelin
@ 2017-01-30 16:51 ` Junio C Hamano
0 siblings, 0 replies; 13+ messages in thread
From: Junio C Hamano @ 2017-01-30 16:51 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, Jeff King, Stefan Beller
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
> Executable files in Windows need to have the extension '.exe', otherwise
> they do not work. Extend the hooks to not just look at the hard coded
> names, but also at the names extended by the custom STRIP_EXTENSION,
> which is defined as '.exe' in Windows.
Will replace, and looks good enough for 'next'. Let's stop
iterating and go incremental if/as needed.
Thanks.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2017-01-30 16:54 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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).