Subject: Re: [PATCH v3 1/3] replay: allow callers to control what happens with empty commits

From: Junio C Hamano <[email-masked]>
Date: Tue, 12 May 2026 13:51:08 +0900

Patrick Steinhardt <[email-masked]> writes:

> +	/* Handle commits that become empty */
>  	if (oideq(&replayed_base_tree->object.oid, &result->tree->object.oid) &&
> -	    !oideq(&pickme_tree->object.oid, &base_tree->object.oid))
> -		return replayed_base;
> +	    !oideq(&pickme_tree->object.oid, &base_tree->object.oid)) {
> +		switch (empty) {
> +		case REPLAY_EMPTY_COMMIT_DROP:
> +			return replayed_base;
> +		case REPLAY_EMPTY_COMMIT_KEEP:
> +			break;
> +		case REPLAY_EMPTY_COMMIT_ABORT:
> +			result->clean = error(_("commit %s became empty after replay"),
> +					      oid_to_hex(&pickme->object.oid));

OK.  merge-ort.h clearly explains what negative values in .clean
member means, so this is a good way to signal a failure up the
call chain.

> +			return NULL;
> +		}
> +	}