git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
From: Réda Housni Alaoui <reda.housnialaoui@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Réda Housni Alaoui <reda.housnialaoui@gmail.com>, git@vger.kernel.org
Subject: Re: Sometimes unable to lock the index during pre-commit hook
Date: Sun, 10 Nov 2019 10:10:57 +0100
Message-ID: <CAE0unxxzBpTr1afmKfQm_nJYo5oFOftih+vE+wQbFW809rXdaA@mail.gmail.com> (raw)
In-Reply-To: <xmqqpni0jioq.fsf@gitster-ct.c.googlers.com>

Thanks for your answer Junio.

As you probably know, many projects (not only mine) format the code
during pre-commit hook.

Could git project consider this widespread usecase?
I guess unlocking the index (after
https://github.com/git/git/blob/master/builtin/commit.c#L419) before
running the hooks is not an option here?
Could a new kind of hook be added to cover this usecase? If I am not
mistaken, this would be similar to prepare-commit-msg which allows to
fail or edit the commit message in place.

Le dim. 10 nov. 2019 à 08:26, Junio C Hamano <gitster@pobox.com> a écrit :
>
> 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.
>
> Thanks.

  reply index

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

Reply instructions:

You may reply publically 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=CAE0unxxzBpTr1afmKfQm_nJYo5oFOftih+vE+wQbFW809rXdaA@mail.gmail.com \
    --to=reda.housnialaoui@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror http://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git