Re: Sometimes unable to lock the index during pre-commit hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Réda Housni Alaoui <reda.housnialaoui@xxxxxxxxx> writes:
>
>> Are pre-commit hooks expected to be able to manipulate the index?
>
> Hooks are described in githooks(5) manual pages; we may want to
> clarify what is not allowed, but back when most of the entries were
> written, the stance was that anything that is not explicitly allowed
> there is forbidden.
>
> In general, a pre-<something> hook is a way to inspect (i.e. look
> but not touch) what is proposed to be done and veto it by exiting
> with non-zero.  It is not expected to change the state of the
> repository in any way.
>
> The code does not necessarily enforce it, because it is costly to
> take a snapshot of everything (including the index, the working tree
> files, the files that are untracked, the objects in the object
> database, etc.) before calling a hook and ensure that the hook did
> not touch anything.

Actually, we do accomodate for the possibility that pre-commit hook
may muck with the on-disk index there days, even though the original
design intention was not to allow random changes there (see ll 960-
in the same file).

So it seems that if we hold the lock necessary to refresh the index
for too long, it may be an option to move the code that unlocks to
somewhere earlier in the callchain.  prepare_index() however returns
different on-disk index file (the real thing when making an as-is
commit, and a temporary one otherwise), and the unlocking rule may
be different, so some restructuring of the code might become
necessary before that can be done.  I dunno.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux