From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.149 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795915865; b=qbcMocxrgP5NWVrXSTG4f0ADyE+T6FWjDubBRa35EwQD++Iczy/0AqH9oMn4v/UEJvhD njf2sgh84B8v6pMdgiacfOnqDtvyYbeV1XImGYVfnTdszPBV+AwhdtN6vFpH7Sac8aRS4 KQS0umWMG9mUDdn1R/CsJ6NpC+/q9RbIhcwtfFaQwdqDgbZh4MPGg6pDFrm8FDU3krTJI FX80srG2inGyNP/+41F+HlQoDJEuDtbJcXv4k8NXIixl6yY8d0RCIQoOwluxt06SrPxH2 Yxpw7s1eigfLg2gPPLdkPHBreOEhPKxraciHXLZX+3zYP8pW5CA3CKFpPZjcdzkytOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795915865; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: User-Agent:MIME-Version:Content-Type; bh=XmwFikw5s01WtB3xd9K8G0W906aKueaiO60GJgHXPeY=; b=IQAMZ3cIM/DCfKN6lGTcZScgNU+jYN7TnEUZGgnu2yFBqrja84z3yHuJKQXpqAboO+O+ AtrD7pMBvQk9itP+V+WJBlvEKk9KXJaW53FzElqFFnXzw+w6ZuxCjSXOhVJ1lm0L3hOrG ijvZBhWdKzR5MKEaRx5J6Qv/FRkUI5Oz5S/pGhvQz4Es7UPkXzKxWHWO7eD1yg4W65nji HjJWqh1VF1GeczM7OZy4VvHmZiISCV6uZZ6+i4vJEjUYG9j9kcMym+XeyUKRKO8lqcziP f+2OFIrvIP3Ud88I9+8PMx0x+uJ6VywSTRM/aQtOyTCIpSIPwa461U2XODfc4YhjESA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=b8S6T3uU; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=i5H7ETYG; arc=none smtp.remote-ip=103.168.172.149 Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C537606A31C for ; Sun, 29 Nov 2026 01:31:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4C537606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=b8S6T3uU; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=i5H7ETYG Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 72EF7EC093A for ; Sat, 28 Nov 2026 20:31:03 -0500 (EST) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-03.internal (MEProxy); Sat, 28 Nov 2026 20:31:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1795915863; x=1796002263; bh=XmwFikw5s0 1WtB3xd9K8G0W906aKueaiO60GJgHXPeY=; b=b8S6T3uUXwiS8arZyHg+Gs/C4Q 8F9kwBxjrVaOpP7erVZt8/yF8tpXTL1e2qDzWWLCEtG2+m6w9bHvjLG2aozv9W62 9gcYHbxuDjCgjNPDOwcxMWf7dscZsqwNAO6D0CgvVPGz4piMfyfMWPmtB30est5D vClwB12a2C/PPQcFAI0TuPZMVdAHCTyOHNnjU0fpgat5UUxco+ixKyXot4PFakjK 36YQZxFXo7/mxm48XCF9svjrxkiE2AZ4V/iFtnhVO8EU+NiMXytY66uiDkJ8mWux u/Y1T8Dpw1mLheqHPOR4L/XEmNYFp4kVbyi6fHoRdTIWSNzxlQBDRUCn+iiw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1795915863; x=1796002263; bh=XmwFikw5s01WtB3xd9K8G0W906aKueaiO60 GJgHXPeY=; b=i5H7ETYGlEHcTbzM5sncfB5qk76LHSVz/svI2Pc+AbK4SxHgPUL huMJCNfRd2Sg1OcqUz5r3gR5E4FbCF7WUjW+DTIeRj0MvbG44yK7Ey3QzbVJ/L3D vjZJu68x81R6VG0io5P6B6+GBgtO1G3Cxijb+TFjE4V0iho/yeE5J/825IyOGnMX Bq29SZnJyPA01LEjH2knFajISl0Yj3mdywbBS2GgM0wyfRV9o1BYO6b+RbfrWs/y Jrzkk3sxtkLM89xIUJhlZu7MBvXzdoPHNJARqdTZ/JuiCthA8jDav+rFtcBHaYBz mCMrwwX6umfV121EQuRIMxokAE3cVeKWK8A== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pobox.com a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1795915863; d=pobox.com; mf=PGdpdHN0ZXJAcG9ib3guY29tPg==; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm2:rsa-sha256:AN/9QkEUACeosTYr3qKgft5h3WyyUUansDl4lYgCh4m7VD1 h7NupPXUuWbUsrx/wX0sCXNHRzo7Nyzdt9m9uw/Wi5/NbdxXqGSzaBf+Z7nbXBI4 M1PoHzI89PI6hQIWeqlU1DxkABRQoWj2bMwxGETaRFs0sl7rCkL9N/a9nQ2owRkX o3gsV1+jXasl82C3mGRhA8kN+APeWXAnQfCg/dG1BP70aK47onz8+Q5v/P3GTpcm CEGAi038vXt481HIZQ9Jpl3LcNufmmQpfgJ6ePRSlp9N1BisQXRk1PDmtj8uH8p5 C3L7cjpl5vBFxD2FHdt7eY6x11+drA191skyIjA==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id, mime-version,references,subject,to,user-agent; Message-Instance: m=1; h=sha256:DBSGyQZ35zNDcGfo8i/RtThg11oL6FNBcBjc+B7Lho8=:Yh3lTvE/NTE7dWnZxR7fgYLXo+tHREay/N3T1rNgGpY=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEBseu65OWvBLyW8n1fpGW+gvC6cnsWUioHuNFIMEIqIozi6idk06BIody7+FIfPF jGhqSNvnrwAfgBKBLTLiFTEf36CRjFs6pp4x/5V9YmaJ710J3nIZC0TgSlMDvRaq7Kckji VQAAhmymVCtM7uy0ECvcbai9rJ0LCOuSNy5WdIonz66uPr8x0RpvqrIbYEv2LsOniojvji R2yv7KYgZlssbnKAK01Adbi0PpaRLE8OAq7pJB2TVG8KWLLdRtd1MaPiYyuyvQD6d+Dvu4 R3SWG5OSBXJwpyEwNzJLHgNPyAaO2gNTFKVRN0Z8n5Q6DZbazeYolEGLWisaTEpvq+3APj IjOq668d3V3jXNHxk7Ct0izrX7C2wgs73mHUAys1FZ97dtzKQjKacAI9/iLj9/haOkkJpB JsLSJJcknqqSNw9X5eierYdE+JA+pcvr6JKlD6Ub321LAwvnuLoFiiFPmoaXFkStyInUbU tJL8n/6abyKH7ptxUuAvAlp+LJuFcb0mF2qZxPN8uPGCMTnWl7dAADPGSt9U7L7nbBgVWI xufHedBRFlYJskING4jYPq/YOPhnFQMM5IxKUNUOWarCHt+svJQ/tVYWvWm6+4ArnnMYPl OjBgI0g7mnTwlyLstqWEhyRHOpaeXTms3lSaL/EJnyNKQJXo/vNHfwtTAiKg X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 28 Nov 2026 20:31:02 -0500 (EST) From: Junio C Hamano To: Erik Cervin-Edin Cc: git@vger.kernel.org, phillip.wood123@gmail.com Subject: Re: [PATCH v5 1/3] commit: write the --fixup subject the way --squash does In-Reply-To: (Erik Cervin-Edin's message of "Sat, 28 Nov 2026 13:13:58 +0100") References: Date: Sat, 28 Nov 2026 17:31:01 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain Erik Cervin-Edin writes: > Two commits that follow teach commit --fixup how to take messages like > --squash. In preparation for that, refactor prepare_to_commit() to > write the --fixup subject in a block before the chain, as --squash does. > Since the two options are mutually exclusive, put each subject block in > its own branch of an if/else-if. Because parse_and_validate_options() already rejects combining --fixup and --squash with a die(), placing the fixup_message and squash_message subject blocks in an if/else-if ahead of the message-source chain is safe and mirrors how --squash already works. > diff --git a/builtin/commit.c b/builtin/commit.c > index 36e47e18ed..698823d4fa 100644 > --- a/builtin/commit.c > +++ b/builtin/commit.c > @@ -781,7 +781,21 @@ static int prepare_to_commit(const char *index_file, const char *prefix, > "pre-commit", NULL)) > return 0; > > - if (squash_message) { > + if (fixup_message) { > + struct pretty_print_context ctx = {0}; > + struct commit *c; > + char *fmt; > + c = lookup_commit_reference_by_name(fixup_commit); > + if (!c) > + die(_("could not lookup commit '%s'"), fixup_commit); > + ctx.output_encoding = get_commit_output_encoding(); > + fmt = xstrfmt("%s! %%s\n\n", fixup_prefix); > + repo_format_commit_message(the_repository, c, fmt, &sb, > + &ctx); > + free(fmt); > + if (have_option_m && !strcmp(fixup_prefix, "amend")) > + die(_("options '%s' and '%s:%s' cannot be used together"), "-m", "--fixup", fixup_message); > + } else if (squash_message) { Checking the remaining arms in prepare_to_commit() confirms that observable behavior is unchanged. At this point in the series, -C, -c, and -F are still rejected alongside --fixup in parse_and_validate_options(), and combining --amend with --fixup explicitly leaves use_message NULL there. As a result, --fixup either enters the have_option_m arm (which now sets hook_arg1 to "message" and appends &message for plain --fixup, while amend/reword with -m already died above) or falls through to the fixup_message arm, which sets hook_arg1 to "message" and calls prepare_amend_commit() for amend/reword. > if (!strcmp(fixup_prefix, "amend")) { > - if (have_option_m) > - die(_("options '%s' and '%s:%s' cannot be used together"), "-m", "--fixup", fixup_message); > - prepare_amend_commit(commit, &sb, &ctx); > + struct pretty_print_context ctx = {0}; > + struct commit *c = lookup_commit_reference_by_name(fixup_commit); > + if (!c) > + die(_("could not lookup commit '%s'"), fixup_commit); > + ctx.output_encoding = get_commit_output_encoding(); > + prepare_amend_commit(c, &sb, &ctx); > } > } else if (!stat(git_path_merge_msg(the_repository), &statbuf)) { > size_t merge_msg_start; Doing a second lookup_commit_reference_by_name(fixup_commit) inside the fixup_message arm for the amend case feels a little bit wasteful, but keeps the subject block cleanly separated from the body block ahead of the final patch. Looking good.