Subject: Re: [PATCH v2] replay: drop commits that become empty

From: Junio C Hamano <[email-masked]>
Date: Thu, 18 Dec 2025 08:49:17 +0900

Phillip Wood <[email-masked]> writes:

>> 	git commit --allow-empty --only -m empty
>> 
>> because without --only, the changes to blah will be taken.
>
> I've got into the habit of always adding "--only" when I want to create 
> an empty commit in case there are staged changes. I don't really like 
> "--allow-empty" as I've never wanted to create commit that might or 
> might not be empty - either I want to create an empty commit in which 
> case I don't want to commit any staged changes, or I want the commit to 
> fail if there are no staged changes). I can remove it if you want.

Being explicit when you are unsure is good, but in this script I
think we should be very sure that the index matches HEAD, so I would
consider that the only effect of the use of the "--only" here is to
puzzle readers.

A comment "# force an empty commit by including no paths" before the
command would work to help unpuzzle readers, though ;-)

Thanks.