Article View: linux.kernel.git
Article #1048Re: [PATCH v3 2/2] commit: allow -c/-C for all kinds of --fixup
From: Phillip Wood
Date: Wed, 21 Oct 2026 15:10
Date: Wed, 21 Oct 2026 15:10
133 lines
15623 bytes
15623 bytes
Hi Erik
On 22/09/2026 14:04, erik@cervined.in wrote:
> From: Erik Cervin-Edin <erik@cervined.in>
>
> The fixup code path in prepare_to_commit() only knows how to take a
> message body from -m or -F. Now that the previous commit allows -m and
> -F for all --fixup variations, -c/-C are the odd ones out.
>
> Teach the fixup path to look up the ref given to -c/-C and seed its
> message when preparing to amend the commit, mirroring what --fixup=amend
> does when no message source is given. With this in place, -m/-F/-c/-C
> all behave consistently across the plain, amend, and reword --fixup
> forms.
>
> The incompatibility check grouping -C, -c, and --fixup can go away
> entirely, as -C and -c are already rejected together by the check that
> groups them with -m and -F.
I'm less convinced about there being much use for combining "--fixup"
with "-C" but I don't see any reason to prevent it.
> @@ -863,6 +863,11 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
> } else if (logfile) {
> if (strbuf_read_file(&sb, logfile, 0) < 0)
> die_errno(_("could not read log file '%s'"), logfile);
> + } else if (use_message) {
by the time we get here we've copied edit_message into use_message if
"-c" was given so this covers "-C" and "-c".
> + struct commit *c = lookup_commit_reference_by_name(use_message);
> + if (!c)
> + die(_("could not lookup commit '%s'"), use_message);
> + prepare_amend_commit(c, &sb, &ctx);
> diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
> index 9b2ecb1356..de3221ea52 100755
> --- a/t/t7500-commit-template-squash-signoff.sh
> +++ b/t/t7500-commit-template-squash-signoff.sh
> @@ -492,6 +492,62 @@ test_expect_success 'commit --fixup works with -F' '
> EOF
> '
>
> +test_expect_success 'commit --fixup works with -C' '
> + commit_for_rebase_autosquash_setup &&
> + git commit --fixup HEAD~ -C HEAD &&
It would be nice to see
GIT_EDITOR=false git commit --fixup HEAD~ -C HEAD
so that we check the editor is not invoked.
> + test_commit_message HEAD <<-EOF
> + fixup! $(git log -1 --format=%s HEAD~2)
> +
> + $(get_commit_msg HEAD~)
> + EOF
> +'
> +
> +test_expect_success 'commit --fixup=amend: works with -c' '
> + commit_for_rebase_autosquash_setup &&
> + test_set_editor : &&
Most of the tests in this file correctly use a subshell when setting the
editor so that they do not affect subsequent tests. It would be nice to
check that the editor actually ran.
GIT_EDITOR="echo edited >>" git commit ---fixup=amend:HEAD -c HEAD~ &&
Thanks
Phillip
> + git commit --fixup=amend:HEAD -c HEAD~ &&
> + test_commit_message HEAD <<-EOF
> + amend! intermediate commit
> +
> + target message subject line
> +
> + target message body line 1
> + target message body line 2
> + EOF
> +'
> +
> +test_expect_success 'commit --fixup=amend:HEAD with -C HEAD and without have the same message' '
> + commit_for_rebase_autosquash_setup &&
> + start=$(git rev-parse HEAD) &&
> +
> + git commit --fixup=amend:HEAD -C HEAD &&
> + git commit --fixup=amend:HEAD -C HEAD &&
> + git log -1 --pretty=%B >with-c &&
> +
> + git reset --hard "$start" &&
> + test_set_editor : &&
> + git commit --fixup=amend:HEAD &&
> + git commit --fixup=amend:HEAD &&
> + git log -1 --pretty=%B >without-c &&
> +
> + test_cmp with-c without-c
> +'
> +
> +test_expect_success 'commit --fixup=amend: with -C copies full subject + body of squash commit' '
> + commit_for_rebase_autosquash_setup &&
> + git commit --squash HEAD~ -m "inner body" &&
> + echo "extra" >>foo &&
> + git add foo &&
> + git commit --fixup=amend:HEAD -C HEAD &&
> + test_commit_message HEAD <<-EOF
> + amend! squash! $(git log -1 --format=%s HEAD~3)
> +
> + squash! $(git log -1 --format=%s HEAD~3)
> +
> + inner body
> + EOF
> +'
> +
> test_expect_success 'commit --fixup=reword: works with -F' '
> commit_for_rebase_autosquash_setup &&
> echo "message from file" >msgfile &&
> @@ -553,9 +609,7 @@ test_expect_success 'invalid message options when using --fixup' '
> echo changes >>foo &&
> echo "message" >log &&
> git add foo &&
> - test_must_fail git commit --fixup HEAD~1 --squash HEAD~2 &&
> - test_must_fail git commit --fixup HEAD~1 -C HEAD~2 &&
> - test_must_fail git commit --fixup HEAD~1 -c HEAD~2
> + test_must_fail git commit --fixup HEAD~1 --squash HEAD~2
> '
>
> cat >expected-template <<EOF
Technical Details
Message-ID:
<de12af28-a64e-4472-8bd4-b65200772dbe@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72732-linux-kernel-git=dewy.ruReferences:
<cover.1779792311.git.erik@cervined.in> <cover.1790082176.git.erik@cervined.in> <39e408e14718f533edc6ed2de6ff41ed961c6e05.1790082176.git.erik@cervined.in>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72732-linux-kernel-git=dewy.ru
From: phillip.wood123@gmail.com (Phillip Wood)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v3 2/2] commit: allow -c/-C for all kinds of --fixup
Date: Wed, 21 Oct 2026 16:10:49 +0100
Organization: Usenet Network
Message-ID: <de12af28-a64e-4472-8bd4-b65200772dbe@gmail.com>
References: <cover.1779792311.git.erik@cervined.in>
<cover.1790082176.git.erik@cervined.in>
<39e408e14718f533edc6ed2de6ff41ed961c6e05.1790082176.git.erik@cervined.in>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="4178330"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:kY1xFvIN0LvKB17bBBeySws7VBk= sha256:K8EKZKILOd1gE7bR4364gvCp2rc7I35q8SluoLCWbuU=
sha1:Ybe/0MGB2xIbOFPptWDoPjt6MnA= sha256:ab62odhn7nQWOspnICmoQ+1gcJxmz95vIj8/fiUgj4U=
Content-Language: en-US
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 68FAA111049; Wed, 21 Oct 2026 18:16:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.148
X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id ayBlnhAFJ8U7;
Wed, 21 Oct 2026 18:16:44 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-72732-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id 84C4F111022; Wed, 21 Oct 2026 18:16:35 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id D708560754F; Wed, 21 Oct 2026 15:10:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1792595454;
b=lbPjFvufgA3HK77w1yPxSJ5kTpVPLhz9xKqbTqvsjAH2JKRlroRA0OIW5f8dvEm6rbEN
6OPM3uRIDLCmPDShKQtRfeDq0+VhX33kozQTzzh8fExCUcHNfoiAopuQrNsQFIb2ppIjr
X8WzfpPiw60BedC5XZB9nGsYTbHpJ/J0kXqMgGKiy83KShaN16FgZ5cPNAC7r9cRJjYCp
VLx9gEbKD+nL/iIf5DHq6pn7kAmo+rUb9cAYKskga7y/gYlql6OGcy1wMypErq2Q3l21L
riQzR0kHidqk7ndENTchiykbkPWAIjA/sAPqGcQzlOEw5UBxQ/wKIj81QiQ2pJgM7/A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792595454;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:Message-ID:Date:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:User-Agent:Reply-To:Subject:To:Cc:References:
Content-Language:From:In-Reply-To:Content-Type:
Content-Transfer-Encoding;
bh=EmYCOxBd/8JatntUy0A1uG6cIed23gNMNTSKp77WnqM=;
b=0h1gWF48Ygm84jPvzOPoESNVKCtljaNhxtc/56DAlhxzBaICvngipkTiDHdb99gSarT0
er6EBvaJeYM5uwKYiUfhvzdbSEqwoXM+KAjeMx70DkUXMDu9qJJjrO61pOVqVBaz62NRn
JHVZPBj3qhNi46UpwCrfkYVJRLhrCsRTLJ2LDbNReeZuG5JKWMOxY5lPl09XjmjRrENvJ
sKSNOyU3ry3I7VgL0BUk8peUazQ3+Gb/vasLCRzTtWCXf0Lfc0dM9eoX9S6sLJaOBoIHM
4vr7j3lQFQ3nSmf0ap609EWuZZKIGWKwGdKmaFUd7wfNxX2PMRFrKgC4DPAXOj9epLw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=St1VcIs5;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id E0212606A320;
Wed, 21 Oct 2026 15:10:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=St1VcIs5
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.48
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792595453;
b=fvs0Ojf2c5LmHNMPE3ZLYXgDoDk6YaXIChU/Ff8lNEc3HAfXc68Fo54v4d3Q2e6pwh5/
byQhxy4MUGuiFVqGIcL6zsCA8herfdOWQOYZEjahkXZsjHhu1LmCHp6+qNLLHok8UioKh
NXMvEYCyVIXVV165CguElNpMZA2zLMdgfpMPcjqTcazcdhzDXfwRYSOfL+AKQ/DY7V1gm
O/S1MlYhViUgf1hJ/hpxwDSjt0zOYL5XpkaMxfNIHg1u9VWRFipbg7FCZz0dt1Jw43npB
87lLpZOjTRkvznBr3UfjggePINvYrRhoJGNCSBtQXzmI8C0r9yUsjYfsyqReuK26msQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792595453;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
Message-ID:Date:MIME-Version:User-Agent:Reply-To:Subject:To:Cc:
References:Content-Language:From:In-Reply-To:Content-Type:
Content-Transfer-Encoding;
bh=EmYCOxBd/8JatntUy0A1uG6cIed23gNMNTSKp77WnqM=;
b=noAI4F3jwe2rn6k7R++L4j8/2bjHO4lFvauPhynB6wXJBonmA8EKjV4BIzcgYotdvTSY
xrsSCwxbgNOryfTN7bjQCeSgY2ZKoW82zEbaiuk7vz75z1wf09krOdixu6NO56kSHMBF/
5O+5MnAC9Ua7/Km0NOea2MOQMUP8iKFAa7CTyORm5C6GCksHijrSNOSYXsvs42Y7+vhbp
f3Be527h3aI1gGSKIlCNl3eRJHZ6nWDNVGzqOnvatgaUb5N4W+2eNbxbMCNq/pSNoV7Qn
sOSK5TBUPx7I7v99nvJ9A7hjit3iEwgJJXoXzJTucGOw82Gz26D4WPp+KPWo3H6wjSA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=St1VcIs5;
arc=none smtp.remote-ip=209.85.128.48
X-Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4717606A31D
for <git@vger.kernel.org>; Wed, 21 Oct 2026 15:10:52 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A4717606A31D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4a1e2957d7eso8640745e9.2
for <git@vger.kernel.org>; Wed, 21 Oct 2026 08:10:52 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792595451; x=1793200251; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:in-reply-to:from
:content-language:references:cc:to:subject:reply-to:user-agent
:mime-version:date:message-id:from:to:cc:subject:date:message-id
:reply-to:content-type;
bh=EmYCOxBd/8JatntUy0A1uG6cIed23gNMNTSKp77WnqM=;
b=St1VcIs5dyR56QgrtX60Lfdh3JrYx4f6bzayMRMPeVOE4qIjCX7tZP3q0aEcCIRB26
9no/UOWoSP+0tsV6U6LEmgUt7Bff7WPqrddhMea0YeESgOpp8PVF2zQDpLEHI4bToPLB
2hPjaAaIZvnu0d6RImAm4vb0tpQAxvffhEEEvHdR27D4TIrgxFuMMB0mvY/+9AnubY9w
U0oD9exs5XSerN6O0ywlFnjg43z7CW3EiUz6q2ktn6YL9BaIR7ZGRsvrEDrsyiIbRdwh
huR2+406+dA4DMiav7GUHeTTVm7a6E2nAM7DV520LIQikeKMooGnpd+LBMB1B+uIWU23
fQeA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792595451; x=1793200251;
h=content-transfer-encoding:content-type:in-reply-to:from
:content-language:references:cc:to:subject:reply-to:user-agent
:mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=EmYCOxBd/8JatntUy0A1uG6cIed23gNMNTSKp77WnqM=;
b=ECASgvWqhGDdLphRwXOLCOsCm1/SbdxOuYpPk3hpNqXdeDwDyUqxk/RgNfE4cNsOMa
BqpoaraLRRNSC25uyESNlmb7tCucUP+2liDf75/+GIOmOsZnJ+jdlOA6ef/VpuvDbDdr
W+ppG3hYe7bQh0JnNGVfdOHrrSLTdtn31vgd6ZQPEtiGOgkjJwdcTMgrJAL0Gnofm4+7
AOCfqni2WhcF+VhcQVDUthCkNylKzyQUG28wlnODTECHiXQQy3Wkcj16FG5X/2MHjXMk
nRTUfxPEAHx2yOVnmeRgX9UWCF6lezkKepDAxW/WTMWXAzg1TdeaNTghzUrp4P6sjjwz
z5ZA==
X-Forwarded-Encrypted: i=1; AKwUvBxYUA4ry3y1cAUseCfO4g2MzuanNGAE5Wo9iKJPfaY6pKJyZ3lcsJkVkN/4fb77hBt+w6U=@vger.kernel.org
X-Gm-Message-State: AFq9FYKzTnIxUG010oRrfwYdGyHwKXeZD2aJWt7kiG+1ttOqY/JAscDr
TSdBH+CHQahbjpUeSak+Ablw4mP8w3pN3Pw0oFuoeWC1Wk+o4wpojUw1
X-Gm-Gg: AYBFou1WplTQFb9BL1J26i73MgWD2VAM/98bsHgrAUbZYMedjXatBbvkwAzvQvO0nr2
mOs4hkdl7SziGVj1uukqVGthXWMU5G3Yj8Gz/t41S0VjSgqykeBRz1TUWztzc3SUoRgigNXMCBr
fLoc5ycjJJ6Jiy7kCfVbM8094AhuwAoU48ktf8mOVtlW45C+LSYoBMuCpybdFjZcD/y6vpE1pCB
S8R8en2Y5sMB/zEXtwQcsD0DTF5zGg93YPIYpvNLYVfyKUfxjig0BMl+3HVchaUl+JuR7mFGz2o
6met3mbiyYBV4B9yGuuwXOqJGQTv+XXgKko5atE+n4Zh8K0dR1SIU773unbwhjqQur6wxXlU9p7
bYRqrm8eDEQ30SH3/CvfXSFaHQ3NoQ9xBDa0xCrVSMnjHMhrU6MV2OJvRqzEq7YKLaKfFre60TQ
kJDPaaro7PXc5iPWN7ezJndKXKySsSibqRrDkzJUUmVB5BGwHymetsjuNA+NoQ8+JqX/0tb1Nb7
xnqJpLWMgsF7n8q3GSf/sto+AO46DgUfsNTqSg9/3z58Sc2yf7ePW1ef9L3XPUvqirbRFinVblb
V9nCxkS81d3GsSd8RDuOPr0mf7JEwuEUJA==
X-Received: by 2002:a05:600d:82c1:b0:4a1:f91a:732e with SMTP id 5b1f17b1804b1-4a1fdb0606dmr54762105e9.12.1792595450768;
Wed, 21 Oct 2026 08:10:50 -0700 (PDT)
X-Received: from ?IPV6:2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f? ([2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f])
by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1fcd25edasm49988125e9.3.2026.10.21.08.10.49
(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
Wed, 21 Oct 2026 08:10:50 -0700 (PDT)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Reply-To: phillip.wood@dunelm.org.uk
X-Cc: gitster@pobox.com
X-In-Reply-To: <39e408e14718f533edc6ed2de6ff41ed961c6e05.1790082176.git.erik@cervined.in>