Article View: linux.kernel.git
Article #4141Re: [PATCH v9 2/4] branch: let delete_branches() name where a branch landed
From: "D. Ben Knoble"
Date: Mon, 30 Nov 2026 16:18
Date: Mon, 30 Nov 2026 16:18
52 lines
14510 bytes
14510 bytes
On Fri, Nov 20, 2026 at 2:32 PM Junio C Hamano <gitster@pobox.com> wrote:
> I wonder if it makes the code structure cleaner to follow if we swap
> the order of checks between "are we doing dry-run" (which is on the
> outside in the current code structure) and "what is the reason we
> remove this branch" (which is the inner if/elseif cascade) by having
> these different message templates (currently a pair of three-message
> sets) in an array and choosing which set to use based on
> "--dry-run". There are of course a few things that are done only in
> the non-dry-run mode (like removing the branch configuration and the
> branch itself). In other words, a code structure like this
>
> const char *msg_templates[2][3] = {
> { "Would delete branch %s ...", ..., ..., },
> { "Deleted branch %s ...", ..., ..., },
> };
> const char *use_msg[3] = msg_templates[!dry_run];
>
> for-each-branch-to-be-deleted {
> compute if branch has landed;
> if (quiet)
> ;
> else if (landed)
> printf(_(use_msg[0]), ...);
> else if (remote_branch)
> printf(_(use_msg[1]), ...);
> else
> printf(_(use_msg[2]), ...);
> if (!dry_run)
> remove branch and its configuration;
> else
> what is only done in dry-run mode (if exists)
> }
>
> may make it easier to follow for readers?
I see this approach in subsequent versions, but: doesn't this mean we
print "deleted…" before actually carrying out the delete? If the
delete is interrupted midway (or after the print-out but before
starting the delete), we inform the user of an operation that hasn't
occurred.
Now, that might be less confusing than deleting and not informing the
user (if the print is interrupted in a hypothetical reverse-order
code), I'm not sure. But I find it a bit odd to say we've done
something we haven't actually done yet. I suppose we could move the
!dry_run conditional actions *before* the messaging?
--
D. Ben Knoble
Technical Details
Message-ID:
<CALnO6CB1pj5D=kUi59w_O=kFQmGtAgLxekka_q39Y5ShcNMF3Q@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76701-linux-kernel-git=dewy.ruReferences:
<pull.2425.git.git.1790667030497.gitgitgadget@gmail.com> <pull.2425.v9.git.git.1795184664.gitgitgadget@gmail.com> <c4513f9ec1315c34b7a75b95bf50bba59043c274.1795184664.git.gitgitgadget@gmail.com> <xmqqeccfpacc.fsf@gitster.g>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76701-linux-kernel-git=dewy.ru
From: ben.knoble@gmail.com ("D. Ben Knoble")
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v9 2/4] branch: let delete_branches() name where a branch landed
Date: Mon, 30 Nov 2026 11:18:25 -0500
Organization: Usenet Network
Message-ID: <CALnO6CB1pj5D=kUi59w_O=kFQmGtAgLxekka_q39Y5ShcNMF3Q@mail.gmail.com>
References: <pull.2425.git.git.1790667030497.gitgitgadget@gmail.com>
<pull.2425.v9.git.git.1795184664.gitgitgadget@gmail.com> <c4513f9ec1315c34b7a75b95bf50bba59043c274.1795184664.git.gitgitgadget@gmail.com>
<xmqqeccfpacc.fsf@gitster.g>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="1466202"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:nEXGRLdH7GcEvtuN9ek/MW0+Qek= sha256:R1nRv3nGDnqMYnCa31NWQbTzJRaC1bPYY3dCPRpSn/0=
sha1:XUvYJ7hRWhT4Q3gQVsAwDF2gVBA= sha256:hCLqwTN43yyV6fYCYwNq8X1xV9QkADtMfL6Bm/bEuVg=
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 297B4125FF4; Mon, 30 Nov 2026 19:18:54 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.949
X-Spam-Status: No, score=-1.949 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, 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.249,
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 i9nhBQxj3Fkf;
Mon, 30 Nov 2026 19:18:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76701-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id C205E125FF1; Mon, 30 Nov 2026 19:18:39 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 13AF32AE41; Mon, 30 Nov 2026 16:18:38 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796055518;
b=cb/YCN+42zvJBnE49WtJUkWMKoThHTW4Lhx4A+4CY/HY0Qj/6ahF3b7tJ5IHf4dr1hbi
eOmei65lIsFF/ogGO69W5u/xLZa9rXuL5uOouLOeUlmO87BW3fD5xMEECE6mZeXb9SBB5
eeJbcjORrBJhBS40ZnB0l+mEDNzfCQKpTQbABm27aOXPdeHtDFaeaQZLNEovrPR2btEyD
GWdj28O7qy2qN4/t9kk77NFHj1V4xaarj482wPtaJ5MyMD3sX6m5+2oNPwBxdxoX0mBZI
elNASoZtrFXru4MUDu/R99DJhBLAC2FOlSZn90s/LwC76HYisPBjDOxzOcz7stngQKg==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796055518;
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:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
References:In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:
Cc:Content-Type:Content-Transfer-Encoding;
bh=GmOh6Rsn7mjyYmxJfyf++viMJrg6BKphfXZMzt0Ubuo=;
b=b3bhpC3bev88KrS/9kD5puV2GrmduXPksNNDHERuUAba0+mbqB6Tf71R7GfRVe0H7unp
I8+nLU8AryWzF6Tduhcgot66C47HHBsB3gKrkwE+Y0C0flhj4R/UoFKmEkcfSulDEgW7n
Ypas9dVNyUomJJ6nM3MImXOqP8OMl0eOZQZjfpzshLueEHPhqf3g4wKLfCw72Kg3wdLaM
xr8jogU3khq9naJiP99GSvVLY6/E3YDX6RTDclcZA4pjl1xfexW04t5yIw+2j2Uzr+GeI
x7wJmSqIuW2tZvK6HQfMMigr7CBFvYjGS/d4PXWXnKCaVXP1hxUMjN4OIXiMgiwaggg==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZrvKrAeL;
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 DEDA2606A32C;
Mon, 30 Nov 2026 16:18:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZrvKrAeL
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.214.169
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796055517;
b=N1t6vYGvDOF3ureRayhiRBZaSpeqKyEKeoJh/Bkery7hT5c0aIjz4kJM/VlLU1k2DA/d
4XcUr5V5hG1aYrFD0LwVTd5WGCv9KrmHNiAPxGYhCb6nZtzUdgQl6zGhw/81rV6wNN6SO
YLFCsGF49+ScHHHTmISOfJTACoeL80JpM/2pSgaTdoBD7OJp0Rxe2LiYqnOSuVdmigVzm
IQDW/HCbmALuJwpfKsZNI/6EcIsS0gMtTb09F1G3i9dteZq0X5pmWPBFPggV8DRpneo3N
uiLjBx/OO6tl+Uqe8FAqH68E2A1EsKlStbR9JPWeJ/H8/OXPzkaXAyhmSLZFmwGlPTA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796055517;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:
MIME-Version:References:In-Reply-To:From:Date:X-Gm-Features:
Message-ID:Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
bh=GmOh6Rsn7mjyYmxJfyf++viMJrg6BKphfXZMzt0Ubuo=;
b=f0d6fdrHwSdRo4O31dcAHo2b7VbkQI/jcsKJWHpg5Xtf7S7AUyzJaWGgPMU5+gQO3eXF
PrbCGYEoPAABQEZcsphmcej1cTxCqamFoQU64iFDiP13Co64wi4OtExat31XKLYQmY3e4
CDq6HUfddT8C2FA/ZJMxJiwlSsKjXQb97Fxu/kMu29PGumdc/DLSQYnnp//9siOV5DXkU
IGHBIZ7LxCzYLX55nJaYZImPOEeRMQPp50o0C33vRmx/cst+1c2wl0QPdrmbVYOqIiufm
PYNUwEntfNMCWFV7yxhGlOi9lKrRKmnrwklfkbURrGXGKj9Bu1zBUk1+H27B7wFHUAw==
X-ARC-Authentication-Results: i=2; 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=20260707 header.b=ZrvKrAeL;
arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.214.169
X-Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169])
(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 B3760606A31C
for <git@vger.kernel.org>; Mon, 30 Nov 2026 16:18:36 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B3760606A31C
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-pl1-f169.google.com with SMTP id d9443c01a7336-2f04f61282dso50068925ad.1
for <git@vger.kernel.org>; Mon, 30 Nov 2026 08:18:36 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1796055516; cv=none;
d=google.com; s=arc-20260327;
b=sYbgKqkqyw3a+tGUvlZJ3WTkiw+HtNeZoKKq23YI2cnJK4uLzIob3iuiEe99sLkyDu
Yag3W3gH6FSxCYzwgNKevoEQBxZCmIWb1tdwobxXo7EsjnpC4jbHjQGVCsukcKFQTpSP
u4nfp9aVJhOCxtL0nPc1ilcAjrnM1vvRBXuNHRsX6SJouiFdGCNx9Wm9y0YVD/WaZmZH
T2Dxibj8Jyi9Mn1Mrt/8n+Zci7jRyCJYMqXWgK3/D95l+RdbSrg4nunzDv/hXXj5Shk/
rZyXOlkIjb2zrCqs2iAHb6ANjb1YAFKdMKcXqjCcXrDXFtao3c+qrZmbDdesy+s1Nxku
VA9g==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:dkim-signature;
bh=GmOh6Rsn7mjyYmxJfyf++viMJrg6BKphfXZMzt0Ubuo=;
fh=jcKmSMVERcDz4A+8imuHOCendKEAubtEqKvDZDLFR3g=;
b=E7JEi6zHHBW24Lub/b6Jdb0MXJGJ0MFfHHsX9j2r69b6rBzxllMxjr4sXL0UaHoXis
+oUOrksJFz5igNSZWhkRM5OXqyz1IHHb7kbNNfmFkSdPnlo9xkEVgKM6L07dA+XEoaj1
r1VUtAABaxizkysaFfcl5z3LzThwjUGMgPeqgUYdM68xAqS5MCBS3ItXWOt02/YX2Zs4
wFlGmBC/pIcMOdgfvZGmszMBF1jk8/9nLmUretrRdZRwA8HljZR7E1mty3fIrKHSp1sA
UULrmPHxzG05CfYxG5f59WbolvIcWBnAo5DoYry9uShWccYeU6LMHm4tdBJInfkEGV7c
ZEhA==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796055516; x=1796660316; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=GmOh6Rsn7mjyYmxJfyf++viMJrg6BKphfXZMzt0Ubuo=;
b=ZrvKrAeLMesFeaT7Ul4TO2N1/sfZ44gzr1iKaiv+E3uXnSUVlhzr/bnjjPUlgiKw/h
idrcsjKcCQn63tSCaB4tEB/mN2XpOXxCd/Eq2aN6QLfSCF+tDTFcmguZPmk7P8grDC2E
Utb6HpFBMpWUkUMlChdhnhfLJKIIniedhIehWrynKATPgsuQNt+OygTl+laGikp8BzEb
KF/pZUV2+HalEqLewu8OlZe/fUPxT+xEcp1OzjiG2SEa1rLVNgH0e+PsvFewrQMrofDF
DwRp2yBWynFPQeFvdUqQ05QehAjBFInUpzKGz/cpMg74+dIrqOUxpN5O68J56eL/CuP7
xY4w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796055516; x=1796660316;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=GmOh6Rsn7mjyYmxJfyf++viMJrg6BKphfXZMzt0Ubuo=;
b=F1qksbTSZAWhItyGAw067PbVpIraTFcFgvlBsIUjNKDOrbxgaKqVarqQunTXLVYzXg
8P5AT+8SCShKlMjU6Trheo1LVk/vHcPZFBriIRdJplOObrUtVYLrxfcOj8YEbXPKpBWr
JKlwlo/pnixz6CQrpMNIksUFwEx9nRCEvNI3eEhMfHAeP00SUm+L5SMcZH2TxYSCMrMk
qrLVvzMGed3EhZLSa05X9lpmVnwlw6ztOWm4pNkk/rxf77yRCOyCasIeaAGjLK37XxV6
zs3r11u3ENIXr9UADLzsrMR62d69pPweo/b5oZwKf+9qLL2+hWVi43RAxpWRaU3MUOns
RDyA==
X-Forwarded-Encrypted: i=1; AL+hErHN95UxMpNT1kscZnY+qHsTMwX17GuSAu9pQGgdA9n8iRK9e0mxOiZZNP8HjD12aK+hw3U=@vger.kernel.org
X-Gm-Message-State: APuU4Z+4AaW1ViUY0DdRfB0xuxwWB/+cmOiR7JmJCr+TjA/XZypj8MHo
MmimTwwW5e5+y4tTtE/gNo44kyuozZyKJ3z8u+47NjEjSC3TFs6IrZLuNpZmvZUDw+yC1Wc00Is
Z6lmr9Kol7u0jlcfLqntGpJj9KKAZnSQ=
X-Gm-Gg: AZFdTZcMa05K6UNdJ4DVmZH56Snx4WLJxq9fzxtmA7SdSf0GOSaKhNk1XXQjJhKVjLS
8Nd3yDQ+nYz23pDfwT2A81RBV+72S/S4AlxU4VCj1AuWFybLPrgdT1FGwDSPCZci+n5IzdHp7dP
hDrZh1jR7J8wanarz/erqooquxkbDsFo26ej/4Zq6kSgd+cycdkxt/oSlst/iRclZg5f3/z2Hzd
TZk5nQdMg54FfXrt9he3wzItf+bFiWbaVZvTi/J5S7vD6ONWVGtBbsWaCmCY/nE1b6Vda7qUcXI
+2xasUG9G3mkBr3cdb+D/seutVo5GsFtqR8ArgyUpIJVQ/MSsTAFdISLZlTSqXTjhUAuYOARTtg
ALX6A+tVDv0yYY3Eo4uzGjs17R0tK8lFPe23T93XzgjXiNnOMRPOkL1BdU3v27gbiBfw2qoTv71
O0wQnoIdo1ukeHD2C0r4yo1oA8muE7WBWBSHxSyecsSOYOdejLvphyhqSIuoAceshJ
X-Received: by 2002:a17:902:ea02:b0:2f0:4168:fb35 with SMTP id
d9443c01a7336-2f04168fe4emr352505635ad.11.1796055516088; Mon, 30 Nov 2026
08:18:36 -0800 (PST)
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-In-Reply-To: <xmqqeccfpacc.fsf@gitster.g>
X-Gm-Features: Aa3M54rSf9qepizxizGqeJmLOS5B3DCPqYNxv8E3wxmdKbWGsOGGpK-D69esj1c
X-Cc: Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com>, git@vger.kernel.org,
Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>, Phillip Wood <phillip.wood123@gmail.com>,
Jasper Mayone <me@jaspermayone.com>, Tuomas Ahola <taahol@utu.fi>,
Harald Nordgren <haraldnordgren@gmail.com>