git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Réda Housni Alaoui" <reda.housnialaoui@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Sometimes unable to lock the index during pre-commit hook
Date: Mon, 11 Nov 2019 11:23:00 +0900	[thread overview]
Message-ID: <xmqqtv7bi22j.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <xmqqpni0jioq.fsf@gitster-ct.c.googlers.com> (Junio C. Hamano's message of "Sun, 10 Nov 2019 16:26:29 +0900")

Junio C Hamano <gitster@pobox.com> writes:

> Réda Housni Alaoui <reda.housnialaoui@gmail.com> 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.

  parent reply	other threads:[~2019-11-11  2:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-09 21:39 Sometimes unable to lock the index during pre-commit hook Réda Housni Alaoui
2019-11-10  7:26 ` Junio C Hamano
2019-11-10  9:10   ` Réda Housni Alaoui
2019-11-11  2:23   ` Junio C Hamano [this message]
2019-11-11 18:37     ` Réda Housni Alaoui

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=xmqqtv7bi22j.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=reda.housnialaoui@gmail.com \
    /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).