From: Chris Torek <chris.torek@gmail.com>
To: "Jan Rüegg" <rggjan@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Destructive pre-commit behaviour and "--all"
Date: Wed, 22 Mar 2023 14:26:12 -0700 [thread overview]
Message-ID: <CAPx1GvfFrUQBDnJ9QYue91ScZb9ctB+tWv2S+pcprVC7dTgdxg@mail.gmail.com> (raw)
In-Reply-To: <CAPx1GvftGM2kpVL9JWWXrjyTRWs+6OxteoJDq9dgeOjuidUGwg@mail.gmail.com>
On Wed, Mar 22, 2023 at 1:00 PM Chris Torek <chris.torek@gmail.com> wrote:
[snip]
> Note that Git could be designed differently (with real databases
> that have roll-forward and roll-back options), but that's a much
> bigger change. ...
I realized on re-reading my reply here that there's an odd bit at
the end. It's because I decided to simplify something away, but
that left the oddness: bigger change than what? So I'll bring the
extra part back in.
For a `git commit` *without* `-a`, Git has a special case: after
it runs the pre-commit hook, it reloads *the* index, as there's
only the one index. This makes it possible to run `git add`
successfully in a pre-commit hook. But when using `--only`,
`--include`, or `--all` / `-a`, there are multiple index files.
Git therefore *doesn't* re-load "the" index.
It would in theory be possible for Git to load *the* index twice,
once before and once after the hook, and compare them to see what
changed, then perhaps try to use that change to update the
additional indices. That would be a pretty big change, but if it
were done right, it might get what you want.
Chris
next prev parent reply other threads:[~2023-03-22 21:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 10:34 Destructive pre-commit behaviour and "--all" Jan Rüegg
2023-03-22 20:00 ` Chris Torek
2023-03-22 21:26 ` Chris Torek [this message]
2023-03-22 21:58 ` Junio C Hamano
2023-03-28 9:33 ` Jan Rüegg
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPx1GvfFrUQBDnJ9QYue91ScZb9ctB+tWv2S+pcprVC7dTgdxg@mail.gmail.com \
--to=chris.torek@gmail.com \
--cc=git@vger.kernel.org \
--cc=rggjan@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.
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).