Subject: Re: Regression introduced in 03267e86

From: Junio C Hamano <[email-masked]>
Date: Mon, 17 Apr 2023 09:54:55 -0700

Lars Kellogg-Stedman <[email-masked]> writes:

> [This behavior was originally reported in
> https://stackoverflow.com/q/76022720/147356.]
>
> Prior to commit 03267e8656, the following sequence would result in an
> empty commit:
>
>     git init testrepo
>     date > testrepo/testfile
>     git -C testrepo add testfile
>     git -C testrepo commit -m test --allow-empty --only
>
> After commit 03267e8656, the same sequence creates a commit that
> contains "testfile". I believe the original behavior was correct,
> based on the documentation for the `--only` option:

It looks like a convoluted way (aka use of an obscure option) to
create something useless (aka an empty root commit), but it should
be allowed and the last step should do what you expected.

> And while that passes all the tests, I'm not sure if its correct; the
> change in 03267e8656 was correcting a memory leak and I'm not sure I
> completely understand the details.

Yeah, figuring out how 03267e86 (commit: discard partial cache
before (re-)reading it, 2022-11-08) broke the behaviour is a good
first step.

Thanks for reporting.