git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Issuing warning when hook does not have execution permission
@ 2014-08-19  6:05 Babak M
  2014-08-19  8:00 ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Babak M @ 2014-08-19  6:05 UTC (permalink / raw)
  To: git

Hi,

I saw that if a hook file is present in .git/hooks and it does not
have execution permissions it is silently ignored.

I thought it might be worthwhile issuing a warning such as "Warning:
pre-commit hook exists but it cannot be executed due to insufficient
permissions".

Not sure if this has been discussed before. I searched the archive but
didn't see anything.

Thoughts, suggestions? Is there anything like that already?

Cheers,
Babak

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Issuing warning when hook does not have execution permission
  2014-08-19  6:05 Issuing warning when hook does not have execution permission Babak M
@ 2014-08-19  8:00 ` Jeff King
  2014-08-19 16:52   ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2014-08-19  8:00 UTC (permalink / raw)
  To: Babak M; +Cc: git

On Tue, Aug 19, 2014 at 04:05:21PM +1000, Babak M wrote:

> I saw that if a hook file is present in .git/hooks and it does not
> have execution permissions it is silently ignored.
> 
> I thought it might be worthwhile issuing a warning such as "Warning:
> pre-commit hook exists but it cannot be executed due to insufficient
> permissions".
> 
> Not sure if this has been discussed before. I searched the archive but
> didn't see anything.
> 
> Thoughts, suggestions? Is there anything like that already?

Once upon a time we shipped sample hooks with their execute bits turned
off, and such a warning would have been very bad.

These days we give them a ".sample" extension (because Windows installs
had trouble with the execute bit :) ), so I think it should be OK in
theory. Installing a new version of git on top of an old one with "make
install" does not clean up old files. So somebody who has continuously
upgraded their git via "make install" to the same directory would have
the old-style sample files. Under your proposal, they would get a lot of
warnings.

However, that change came in v1.6.0, just over 6 years ago. We can
probably discount that (and if it does happen, maybe it is time for that
someone to clean up the other leftover cruft from past git installs).

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Issuing warning when hook does not have execution permission
  2014-08-19  8:00 ` Jeff King
@ 2014-08-19 16:52   ` Junio C Hamano
  2014-08-20  8:55     ` Chris Packham
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2014-08-19 16:52 UTC (permalink / raw)
  To: Jeff King; +Cc: Babak M, git

Jeff King <peff@peff.net> writes:

> On Tue, Aug 19, 2014 at 04:05:21PM +1000, Babak M wrote:
>
>> I saw that if a hook file is present in .git/hooks and it does not
>> have execution permissions it is silently ignored.
>> 
>> I thought it might be worthwhile issuing a warning such as "Warning:
>> pre-commit hook exists but it cannot be executed due to insufficient
>> permissions".
>> 
>> Not sure if this has been discussed before. I searched the archive but
>> didn't see anything.
>> 
>> Thoughts, suggestions? Is there anything like that already?
>
> Once upon a time we shipped sample hooks with their execute bits turned
> off, and such a warning would have been very bad.
>
> These days we give them a ".sample" extension (because Windows installs
> had trouble with the execute bit :) ), so I think it should be OK in
> theory. Installing a new version of git on top of an old one with "make
> install" does not clean up old files. So somebody who has continuously
> upgraded their git via "make install" to the same directory would have
> the old-style sample files. Under your proposal, they would get a lot of
> warnings.
>
> However, that change came in v1.6.0, just over 6 years ago. We can
> probably discount that (and if it does happen, maybe it is time for that
> someone to clean up the other leftover cruft from past git installs).

The above all sounds very sensible.

We have another code path that looks for an executable, finds one
with no execute permission and decides not to execute it, and I
wonder if we should use the same criteria to decide to give (or not
give) a warning as the one used in the other code path (i.e. looking
up "git-foo" executable when the user runs "git foo").

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Issuing warning when hook does not have execution permission
  2014-08-19 16:52   ` Junio C Hamano
@ 2014-08-20  8:55     ` Chris Packham
  2014-08-20 10:19       ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Packham @ 2014-08-20  8:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, Babak M, git

On Wed, Aug 20, 2014 at 4:52 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Jeff King <peff@peff.net> writes:
>
>> On Tue, Aug 19, 2014 at 04:05:21PM +1000, Babak M wrote:
>>
>>> I saw that if a hook file is present in .git/hooks and it does not
>>> have execution permissions it is silently ignored.
>>>
>>> I thought it might be worthwhile issuing a warning such as "Warning:
>>> pre-commit hook exists but it cannot be executed due to insufficient
>>> permissions".
>>>
>>> Not sure if this has been discussed before. I searched the archive but
>>> didn't see anything.
>>>
>>> Thoughts, suggestions? Is there anything like that already?
>>
>> Once upon a time we shipped sample hooks with their execute bits turned
>> off, and such a warning would have been very bad.
>>
>> These days we give them a ".sample" extension (because Windows installs
>> had trouble with the execute bit :) ), so I think it should be OK in
>> theory. Installing a new version of git on top of an old one with "make
>> install" does not clean up old files. So somebody who has continuously
>> upgraded their git via "make install" to the same directory would have
>> the old-style sample files. Under your proposal, they would get a lot of
>> warnings.
>>
>> However, that change came in v1.6.0, just over 6 years ago. We can
>> probably discount that (and if it does happen, maybe it is time for that
>> someone to clean up the other leftover cruft from past git installs).
>
> The above all sounds very sensible.
>
> We have another code path that looks for an executable, finds one
> with no execute permission and decides not to execute it, and I
> wonder if we should use the same criteria to decide to give (or not
> give) a warning as the one used in the other code path (i.e. looking
> up "git-foo" executable when the user runs "git foo").
> --

I actually find the existing behaviour useful. If I want to disable a
hook to I can just chmod -x .git/hook/... and I then chmod +x it when
I want to re-enable it. I guess I could live with an extra warning as
long as the command still succeeds.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Issuing warning when hook does not have execution permission
  2014-08-20  8:55     ` Chris Packham
@ 2014-08-20 10:19       ` Jeff King
  2014-08-20 17:51         ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2014-08-20 10:19 UTC (permalink / raw)
  To: Chris Packham; +Cc: Junio C Hamano, Babak M, git

On Wed, Aug 20, 2014 at 08:55:52PM +1200, Chris Packham wrote:

> I actually find the existing behaviour useful. If I want to disable a
> hook to I can just chmod -x .git/hook/... and I then chmod +x it when
> I want to re-enable it. I guess I could live with an extra warning as
> long as the command still succeeds.

You could do the same thing "mv $hook $hook.disabled" but it involves
retraining your fingers. I kind of agree that the existing system of
respecting the executable bit is nice, though: it does what you told it
to do, and a misconfiguration is your problem, not the system's. It's
perhaps worth changing if people frequently get the executable-bit thing
wrong, but I don't know whether they do or not.

I kind of feel like we had a similar discussion around items in PATH,
but I don't remember how it resolved.

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Issuing warning when hook does not have execution permission
  2014-08-20 10:19       ` Jeff King
@ 2014-08-20 17:51         ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2014-08-20 17:51 UTC (permalink / raw)
  To: Jeff King; +Cc: Chris Packham, Babak M, git

Jeff King <peff@peff.net> writes:

> On Wed, Aug 20, 2014 at 08:55:52PM +1200, Chris Packham wrote:
>
>> I actually find the existing behaviour useful. If I want to disable a
>> hook to I can just chmod -x .git/hook/... and I then chmod +x it when
>> I want to re-enable it. I guess I could live with an extra warning as
>> long as the command still succeeds.
>
> You could do the same thing "mv $hook $hook.disabled" but it involves
> retraining your fingers. I kind of agree that the existing system of
> respecting the executable bit is nice, though: it does what you told it
> to do, and a misconfiguration is your problem, not the system's. It's
> perhaps worth changing if people frequently get the executable-bit thing
> wrong, but I don't know whether they do or not.
>
> I kind of feel like we had a similar discussion around items in PATH,
> but I don't remember how it resolved.

I don't either, but IIRC the primary tricky point was what happens
when a component of $PATH list is inaccessible, making us unable to
even know if an executable we are looking for exists there or not,
which is slightly a different issue.

And I also kind of agree that the existing system is nice.  It may
sound like a good idea to warn when there is even a slight chance of
misconfiguration on the user's side, but for this particular one, it
has been a designed-in behaviour for a long time, and it may be
unwise to change it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-20 17:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-19  6:05 Issuing warning when hook does not have execution permission Babak M
2014-08-19  8:00 ` Jeff King
2014-08-19 16:52   ` Junio C Hamano
2014-08-20  8:55     ` Chris Packham
2014-08-20 10:19       ` Jeff King
2014-08-20 17: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).