git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: samuelyvon9@gmail.com
Cc: git@vger.kernel.org, gitgitgadget@gmail.com
Subject: Re: [PATCH] builtin-commit: re-read file index before launching editor
Date: Tue, 09 Nov 2021 10:11:04 +0100	[thread overview]
Message-ID: <211109.868rxxvgdi.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <20211109030804.261493-1-samuelyvon9@gmail.com>


On Mon, Nov 08 2021, samuelyvon9@gmail.com wrote:

> From: Samuel Yvon <samuelyvon9@gmail.com>
>
>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>> The code you're moving around has a comment which seems to suggest that
>> what you want *is* the desired behavior, i.e. we re-read it before
>> invoking the editor, so we should have the updated diff, but just don't?
>
> My understanding is that it was once the behaviour and has changed over time.
> I am saying this based on
> https://lore.kernel.org/git/xmqqk0yripca.fsf@gitster.c.googlers.com/t/#u
>
> Specifically,
>
>> Junio C Hamano <gitster@pobox.com> writes:
>> Even before ec84bd00 (git-commit: Refactor creation of log message.,
>> 2008-02-05), the code anticipated that pre-commit may touch the index
>> and tried to cope with it.
>> However, ec84bd00 moved the place where we re-read the on-disk index
>> in the sequence, and updated a message that used to read:
>> 
>> -    /*
>> -     * Re-read the index as pre-commit hook could have updated it,
>> -     * and write it out as a tree.
>> -     */
>> 
>> to:
>> 
>> +    /*
>> +     * Re-read the index as pre-commit hook could have updated it,
>> +     * and write it out as a tree.  We must do this before we invoke
>> +     * the editor and after we invoke run_status above.
>> +     */
>> 
>> Unfortunately there is no mention of the reason why we "must" here.
>
> Looking at ec84bd00 (git-commit: Refactor creation of log message., 2008-02-05),
> we can see that the editor is launched after the cache has been reset. The only
> part that troubles me is the line in the comment that specifies that "we must do
> this ... after we invoke run_status above". I have tested (with my limited knowledge
> of the internals of git) and it seems to be of no consequence of flushing before
> the call to run_status, but I might be missing something.
>
>> The code you're moving around has a comment which seems to suggest that
>> what you want *is* the desired behavior, i.e. we re-read it before
>> invoking the editor, so we should have the updated diff, but just don't?
>
> I think this is the case (based on the previously linked conversation).

*nod*, the implicit suggestion here being: Let's put more of that
summary into the commit message. It helps when looking up/discovering
older behavior.

The comment was first added in 2888605c649 (builtin-commit: fix
partial-commit support, 2007-11-18), and quite suspicuous in timing is
f5bbc3225c4 (Port git commit to C., 2007-11-08) where we moved from
git-commit.sh.

It's a bit of a pain to build git that old, but my hunch is that perhaps
this was tested with git-commit.sh, where the reading of the index would
be another process.

  reply	other threads:[~2021-11-09  9:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09  2:06 [PATCH] builtin-commit: re-read file index before launching editor Samuel Yvon via GitGitGadget
2021-11-09  2:32 ` Ævar Arnfjörð Bjarmason
2021-11-09  3:08   ` samuelyvon9
2021-11-09  9:11     ` Ævar Arnfjörð Bjarmason [this message]
2021-11-09 15:22       ` Samuel Yvon
2021-11-09 18:36         ` Junio C Hamano
2021-11-09 20:01           ` Samuel Yvon
2021-11-11 22:09             ` Junio C Hamano
2021-11-09 16:41 ` Description of github.com/git/git, was " Johannes Schindelin
2021-11-09 17:01   ` Samuel Yvon
2021-11-09 19:03   ` Junio C Hamano
2021-11-09 19:23     ` Taylor Blau
2021-11-09 19:27     ` Samuel Yvon
2021-11-10 12:22       ` Johannes Schindelin
2021-11-11 17:55 ` [PATCH v2] builtin-commit: re-read file index before run_status Samuel Yvon via GitGitGadget
2021-11-12 23:23   ` Junio C Hamano
2021-11-17 16:48     ` Samuel Yvon
2021-11-18 23:51       ` Junio C Hamano

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=211109.868rxxvgdi.gmgdl@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=samuelyvon9@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).