Article View: linux.kernel.git
Article #2341[PATCH v3 1/2] maintenance: report lock acquisition failures
From: Pushkar Singh
Date: Wed, 04 Nov 2026 17:34
Date: Wed, 04 Nov 2026 17:34
87 lines
13721 bytes
13721 bytes
When git maintenance run fails to acquire the maintenance
lock, report the failure instead of silently succeeding.
For automatic invocations, print a warning while preserving
the successful exit status. For manual invocations, report
the failure as an error and return a non-zero exit status.
Respect the --quiet option when reporting the failure.
Signed-off-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com>
---
builtin/gc.c | 15 +++++++++++----
t/t7900-maintenance.sh | 24 ++++++++++++++++++++++++
2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index 81cecf6b6c..9ca9a3584b 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -1402,6 +1402,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
enum auto_gc_hook_result auto_gc_hook_result = AUTO_GC_HOOK_UNDECIDED;
if (repo_hold_lock_file_for_update(r, &lk, lock_path, LOCK_NO_DEREF) < 0) {
+ int err = errno;
/*
* Another maintenance command is running.
*
@@ -1409,11 +1410,17 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
* recursive process stack. Do not report an error in
* that case.
*/
- if (!opts->auto_flag && !opts->quiet)
- warning(_("lock file '%s' exists, skipping maintenance"),
- lock_path);
+ if (!opts->quiet) {
+ struct strbuf buf = STRBUF_INIT;
+ unable_to_lock_message(lock_path, err, &buf);
+ if (opts->auto_flag)
+ warning("%s", buf.buf);
+ else
+ error("%s", buf.buf);
+ strbuf_release(&buf);
+ }
free(lock_path);
- return 0;
+ return opts->auto_flag ? 0 : -1;
}
free(lock_path);
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index 9d610a29fe..3288efb391 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -387,6 +387,30 @@ test_expect_success 'loose-objects task' '
test_cmp packs-between packs-after
'
+test_expect_success 'auto maintenance warns when lock exists' '
+ test_when_finished "rm -f err .git/objects/maintenance.lock" &&
+ : >.git/objects/maintenance.lock &&
+ git maintenance run --auto --no-quiet 2>err &&
+ test_grep "Unable to create.*maintenance\.lock" err &&
+ test_path_is_file .git/objects/maintenance.lock
+'
+
+test_expect_success 'manual maintenance fails with existing lock' '
+ test_when_finished "rm -f err .git/objects/maintenance.lock" &&
+ : >.git/objects/maintenance.lock &&
+ test_must_fail git maintenance run --no-quiet 2>err &&
+ test_grep "maintenance\.lock" err &&
+ test_path_is_file .git/objects/maintenance.lock
+'
+
+test_expect_success 'manual maintenance with --quiet suppresses diagnostic' '
+ test_when_finished "rm -f err .git/objects/maintenance.lock" &&
+ : >.git/objects/maintenance.lock &&
+ test_must_fail git maintenance run --quiet 2>err &&
+ test_must_be_empty err &&
+ test_path_is_file .git/objects/maintenance.lock
+'
+
test_expect_success 'maintenance.loose-objects.auto' '
git repack -adk &&
GIT_TRACE2_EVENT="$(pwd)/trace-lo1.txt" \
--
2.53.0
Technical Details
Message-ID:
<20261104173422.20725-2-pushkarkumarsingh1970@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-74457-linux-kernel-git=dewy.ruReferences:
<20261102122955.143018-2-pushkarkumarsingh1970@gmail.com> <20261104173422.20725-1-pushkarkumarsingh1970@gmail.com>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-74457-linux-kernel-git=dewy.ru
From: pushkarkumarsingh1970@gmail.com (Pushkar Singh)
Newsgroups: linux.kernel.git
Subject: [PATCH v3 1/2] maintenance: report lock acquisition failures
Date: Wed, 4 Nov 2026 17:34:21 +0000
Organization: Usenet Network
Message-ID: <20261104173422.20725-2-pushkarkumarsingh1970@gmail.com>
References: <20261102122955.143018-2-pushkarkumarsingh1970@gmail.com>
<20261104173422.20725-1-pushkarkumarsingh1970@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3445917"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:cDj71CtUmO9hLKHhLLRlmIggeqk= sha256:b3zbDA87telaZb50lH7BIe5WWelDzhBcPghOTWPxXYQ=
sha1:gBnTrLjGW22MEUQ7K9hsEPRoRXc= sha256:HU/pLMoIl+4vE5kkKWdhnF7lid6Au2nHMJSuDhFO6wc=
List-ID: <git.vger.kernel.org>
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id BB9F3112C66; Wed, 4 Nov 2026 20:57:41 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 1.609
X-Spam-Level: *
X-Spam-Status: No, score=1.609 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, RCVD_IN_SBL_CSS=3.558,
SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no 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 cdLwDHgeipoG;
Wed, 4 Nov 2026 20:57:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=git+bounces-74457-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id 16350112CB9; Wed, 4 Nov 2026 20:57:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sin.lore.kernel.org (Postfix) with ESMTP id 3F5B2390A1; Wed, 4 Nov 2026 17:39:11 +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=1793813721;
b=vael0AkKAzgeNV//uL5mpZe04jBWWo5SkJHBuUPHEcX/cpkqLz1SvXSST2alM+HTJjt1
qtoYJl8570hGeV4gUEn9G3Lph74pSMGJDyV3RfEuOp4RkaYxmNH4FPwBLgz5SH8dUHzPC
0efRuwxqtGVCAXkqlnmFPPjVfIj/gl+PXalJFmIclDHGG/HpQZxc8PRjtUE7w90hOBGyt
nLG6VWw5dFVyquoBPvrBHfOwKEuIXcmwqclVt+HlEbZsijfw6isVH/Eu2NAVW9+5v9BCy
SVxiepaB4bG20DPgNr5Kb7uuGc+R68+86P0G7jM6nwjJXykQYFqs21UkYUY2KgvlIQg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793813721;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=+xELJ96simVANEH3A52Xutazq4TyciqcjvfvVc3nZ7c=;
b=k7lu8hqbrkauU1eC1oC1qdWcXyfUFwUaP5fX6+LEZdXbn1j5T1i1YDdpzRHCjXNICa6g
BalqOlEOhGiiksWardwhhL9cfIpLerP8sI/UOk1lNBRXLodeQ7piH17h+m/7gOYvjvc3Q
GJGj8uFAvnlBNKGod45CAS62vt4gYK95umY/sr/zD3a3ajHSZX9ZaaP3DMeqd1jIlARYF
ZTlv7DihJwHAdHkaFk6ZconXM0QVEHs7jLXrPKrgb6fkj6dkx6viW37+/bnUiXSsmAoH1
V/SI9GmTD4mz0hiF+UaJaQtudF+3HdcWWQEDgd4Jrzty3gjahMCwfzrgt97iuxdc0Dg==
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=20260707 header.b=lZXFiHEZ;
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 23284606A33F;
Wed, 4 Nov 2026 17:35:21 +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=20260707 header.b=lZXFiHEZ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.182
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793813720;
b=Eq4G6HNbQ4ort3HmS9XlzBs0ejeaoHIhdcBflKFZs4bbIAgxOzDvzdZCqEekhzJrHMnh
RUaEP5woDSL2tjnEHFfprLRw6Ekjp1CJ4/gPqVfRdmhe/jxLDEJQD1SIk/zigu5SNQHGp
mr9/pD5FQiGl/ivguVJjoCiR6PMlVhzzwLi1gAie4y60XsH8svoovWo9k5oYE7SlB0asc
2S9L04wQxr0gld4k4qpso02j6Kv+5nrrD+96Nsi3sYvtsa6NIVjuYpJ7L04pn7CDttOr7
DaPBx5NLsscSsrVxFbDlRa46J6U8b2ZF8l9tgmGgrxPO8FgJ7qXt9PgwfbqVfb0nd3A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793813720;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=+xELJ96simVANEH3A52Xutazq4TyciqcjvfvVc3nZ7c=;
b=Dm1Vw9C0QBKjyW0z5TxdzzUElSoZqs7U5VkBsFRYFLfV43vbW2Ol5wJb/E2LVy1fHmTT
JSwHHsu8lCNv/hRRfaCoo1YhJXLVMNbeyi115y7Dblz88Vu0Y9oXE2V+UxqFLAkVrj/D7
f7i4AMY4wc0fgO6ylsvd9EWBeLqJuuowdlitfvG/kmfjGNtxi8JdsvekN7F2/SdUVT+44
u80cHZsBHh0jIzsDY2Ya7zGbNBH/rDVIJ6yHx5MJe9WCfnyfewXz/PqxpIsSizR4VFrW/
z8BLcYYAE6rdvIO3bba8cgArRxjSiJqyRuWCKkkquG85JQoVb7YbhpEIpX1KUcDj7wQ==
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=20260707 header.b=lZXFiHEZ;
arc=none smtp.remote-ip=74.125.82.182
X-Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182])
(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 E1863606A329
for <git@vger.kernel.org>; Wed, 4 Nov 2026 17:35:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E1863606A329
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-dy1-f182.google.com with SMTP id 5a478bee46e88-36cedf1bd63so1021371eec.1
for <git@vger.kernel.org>; Wed, 04 Nov 2026 09:35:19 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793813719; x=1794418519; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=+xELJ96simVANEH3A52Xutazq4TyciqcjvfvVc3nZ7c=;
b=lZXFiHEZQnErmgX4CWJCeliwnpyrmU5q3oJQfFBNtM5qfSD9X1kV0+wGWZEtj776gW
wTlxpiCLkj9OoTAhmfJqUzLX4KVthR+sfyeADxJBkg9Oham4YgVL9uHA9Ud6WUAKqrcd
CtPNU50pdBLXAVUsyQDH/ZL995t/EALG35ec+gwADRdYqwG5b6arQyzGWi6juYdvQCzm
/XYJXgTEnnPJxb+dEz9thvgsLtGIERpEiqQA9qrZf41CS/mnePTvHCaD4A0tGgKROTdC
Afc/QqtWvgODqUCtnxH363oYZE0aimmXI6Tfb61XfgdSJLldFhPTUty96vC/TRJ09RC+
vZQw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793813719; x=1794418519;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=+xELJ96simVANEH3A52Xutazq4TyciqcjvfvVc3nZ7c=;
b=RFqEi0u7D+iFJiSA0JsTK6QGUScQo/aMaoZ7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JRoROc1J6m6aE36s9Zcc5IoJEQTaFi2NGhFyJ15w==
X-Received: by 2002:a05:701a:ca06:b0:196:b805:9546 with SMTP id a92af1059eb24-1b24f43f63dmr196069c88.10.1793813718580;
Wed, 04 Nov 2026 09:35:18 -0800 (PST)
X-Received: from HP-V15.xu.edu.in ([125.22.10.135])
by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b245c4f83fsm13520264c88.17.2026.11.04.09.35.15
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 04 Nov 2026 09:35:18 -0800 (PST)
X-Cc: gitster@pobox.com,
mail@thomasbachem.com,
ps@pks.im,
ttaylorr@openai.com,
Pushkar Singh <pushkarkumarsingh1970@gmail.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261104173422.20725-1-pushkarkumarsingh1970@gmail.com>
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