Article View: linux.kernel.git
Article #4346[PATCH] mktree, bisect, remote: load the default config
From: Aman Ganapathy
Date: Fri, 04 Dec 2026 22:56
Date: Fri, 04 Dec 2026 22:56
167 lines
16425 bytes
16425 bytes
When core.fsync is set, the expected result is that whatever components
it lists get synced to disk, no matter which command writes them.
Implementation wise, core.fsync is only parsed when a command loads the
default config with git_default_config(). "git mktree", "git bisect"
and "git remote" never do this, so they keep the built-in default,
which doesn't sync loose objects or refs. What this means is that even
with core.fsync=all, mktree doesn't sync the tree it writes, and bisect
and "remote rename" don't sync the refs they write.
mktree is where this hurts the most. A script that builds a commit with
hash-object, mktree, commit-tree and update-ref would expect all of it
to be synced, but the tree isn't. On XFS and ext4, a crash shortly
after can leave the branch pointing at a commit whose tree is an empty
file, and "git status" then fails with "loose object ... is corrupt".
Fix this by loading the default config in all three, like 29c83fc23f
(interpret-trailers: load default config, 2019-06-19) did.
Signed-off-by: Aman Ganapathy <amanganapathy@gmail.com>
---
I was testing crashes with core.fsync=all, and a commit built with
plumbing came back with an empty tree, even though the commit and the
branch were fine. Here's roughly what I ran on an XFS loop mount:
git config core.fsync all
git commit -q --allow-empty -m one && sync
blob=$(echo hi | git hash-object -w --stdin)
tree=$(printf '100644 blob %s\tf\n' $blob | git mktree)
git update-ref HEAD $(echo two | git commit-tree $tree -p HEAD)
git update-ref refs/heads/other HEAD
xfs_io -x -c shutdown /mnt
The second update-ref is just any later command that syncs something,
without it the branch goes back to "one". After remounting, "git
status" fails on the empty tree. With the patch the tree is fine.
These were the only three I found, but I only traced a dozen or so
commands, so there could be others. I can also split this into one patch per command if that's preferred!
builtin/bisect.c | 4 ++++
builtin/mktree.c | 3 +++
builtin/remote.c | 2 ++
t/t1010-mktree.sh | 11 +++++++++++
t/t5505-remote.sh | 13 +++++++++++++
t/t6030-bisect-porcelain.sh | 10 ++++++++++
6 files changed, 43 insertions(+)
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 1cfb8a794b..9bb886a9bf 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -2,6 +2,7 @@
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "builtin.h"
+#include "config.h"
#include "copy.h"
#include "environment.h"
#include "gettext.h"
@@ -1615,6 +1616,9 @@ int cmd_bisect(int argc,
OPT_SUBCOMMAND("run", &fn, cmd_bisect__run),
OPT_END()
};
+
+ repo_config(repo, git_default_config, NULL);
+
argc = parse_options(argc, argv, prefix, options, git_bisect_usage,
PARSE_OPT_SUBCOMMAND_OPTIONAL);
diff --git a/builtin/mktree.c b/builtin/mktree.c
index 45ae2af3b5..1b4d9d8ccc 100644
--- a/builtin/mktree.c
+++ b/builtin/mktree.c
@@ -4,6 +4,7 @@
* Copyright (c) Junio C Hamano, 2006, 2009
*/
#include "builtin.h"
+#include "config.h"
#include "gettext.h"
#include "hex.h"
#include "quote.h"
@@ -170,6 +171,8 @@ int cmd_mktree(int ac,
OPT_END()
};
+ repo_config(repo, git_default_config, NULL);
+
ac = parse_options(ac, av, prefix, option, mktree_usage, 0);
getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
diff --git a/builtin/remote.c b/builtin/remote.c
index fb7e5b114f..e53e9db3fa 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -1952,6 +1952,8 @@ int cmd_remote(int argc,
OPT_END()
};
+ repo_config(repo, git_default_config, NULL);
+
argc = parse_options(argc, argv, prefix, options, builtin_remote_usage,
PARSE_OPT_SUBCOMMAND_OPTIONAL);
diff --git a/t/t1010-mktree.sh b/t/t1010-mktree.sh
index cecba55d45..893b6e4628 100755
--- a/t/t1010-mktree.sh
+++ b/t/t1010-mktree.sh
@@ -117,4 +117,15 @@ test_expect_success PIPE 'mktree --batch survives a concurrent repack retiring a
)
'
+test_expect_success 'mktree syncs the tree' '
+ test_when_finished "rm -f input trace2.txt" &&
+ blob=$(echo sync | git hash-object -w --stdin) &&
+ printf "100644 blob %s\tsync\n" "$blob" >input &&
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
+ GIT_TEST_FSYNC=true \
+ git -c core.fsync=loose-object -c core.fsyncMethod=fsync \
+ mktree <input &&
+ test_grep "\"name\":\"hardware-flush\",\"count\":1}" trace2.txt
+'
+
test_done
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 8b4c7006ec..745687a74b 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -1883,4 +1883,17 @@ test_expect_success 'rename moves around the reflog' '
test_cmp expect reflog-entries-new
'
+test_expect_success 'remote rename syncs the renamed refs' '
+ test_when_finished "rm -rf fsync trace2.txt" &&
+ git init fsync &&
+ test_commit -C fsync one &&
+ git -C fsync remote add origin ../nowhere &&
+ git -C fsync update-ref refs/remotes/origin/main HEAD &&
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
+ GIT_TEST_FSYNC=true \
+ git -C fsync -c core.fsync=reference -c core.fsyncMethod=fsync \
+ remote rename origin upstream &&
+ test_grep "\"name\":\"hardware-flush\",\"count\":1}" trace2.txt
+'
+
test_done
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index d5e7987f56..1e25b5d493 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -1392,4 +1392,14 @@ test_expect_success 'verify correct error message' '
test_grep "git bisect good.*exited with error code" error
'
+test_expect_success 'bisect syncs its refs' '
+ test_when_finished "git bisect reset && rm -f trace2.txt" &&
+ git bisect start &&
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
+ GIT_TEST_FSYNC=true \
+ git -c core.fsync=reference -c core.fsyncMethod=fsync \
+ bisect bad &&
+ test_grep "\"name\":\"hardware-flush\",\"count\":1}" trace2.txt
+'
+
test_done
--
2.39.5 (Apple Git-154)
Technical Details
Message-ID:
<20261204225641.12294-1-amanganapathy@gmail.com>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mi.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-77036-linux-kernel-git=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mi.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-77036-linux-kernel-git=dewy.ru
From: amanganapathy@gmail.com (Aman Ganapathy)
Newsgroups: linux.kernel.git
Subject: [PATCH] mktree, bisect, remote: load the default config
Date: Fri, 4 Dec 2026 14:56:41 -0800
Organization: Usenet Network
Message-ID: <20261204225641.12294-1-amanganapathy@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2896642"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3CY2xV309h/9slCX0fWja5LWQMU= sha256:flC6Xo4aXugKxcBXTt7FmlfJ/eLcuNSnAGtUNC+m8/o=
sha1:xxLPvko9SRn3xa1YC2Dmb/7L7+8= sha256:wawmjpLbi753jly7yPZH63TVLgzsO2xLnLkWLxn8CLY=
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 ED1C8117D17; Sat, 5 Dec 2026 01:57:01 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.196
X-Spam-Status: No, score=-2.196 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.001,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=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 62jeVYzaiy0s;
Sat, 5 Dec 2026 01:56:55 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-77036-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 CD0F3117D13; Sat, 5 Dec 2026 01:56:46 +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 68C473895E; Fri, 4 Dec 2026 22:56:45 +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=1796425005;
b=dlAiMqS+fqHnfx+T6dM4FP9KHEYLRRLr0BdFCGo5lISxpYw3TE1Vfns84KCsu7HGQXTr
zcqRxCLEh4LUFAQ0iX3cCMPbgSpwD3tf0xz/CWSGNc3XxAfoNd09iUmH4ecVZm+GmkQB7
1PZb7dQUK1lAINJT/3ih6OWJqS9UT4IYCMxjAv8lQF16ezjY+ceNIrBQx/x7H6FgmouC+
89Xr95v7dL78MuZpSCk0hjXrVOEP+LeywVNmQ9i6Po7vRO3Yvpbh+TnEnkQJoFY6740cp
zojVdw2aBMddzOtmc4N2fUVEyNjO/bkYcvek2VHM6QWS57z3IkP6U8A8VYGttvZWe7g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796425005;
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:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
bh=tni4vlTMjlXKoDcAfyoUx2O2o30OFDLWW6FZclB6Z7k=;
b=D2XNpT5yT9bNm2Pa4/yPID5HnpNPQivnbwCHeJjoPX3ue0r0pr4zOBmvyHV63fYjHYDv
WUctyO3Q7+43RR2bk5/aaJVqbZv+Q/jAd+8+NOr2CZhAmBkJEs98D4SvLwRJFYwPDBkn0
iqzUlCbA6zC3y6mMo9aO43R2RtxxxsY5tqJeoIVeoGBjsj2OBwIIWMwKfNGxJSI51gDwa
4lxv3ktvXbxS0Awm43hi1y4GDWxil8DsrELkTRrm1uuFd+ZFAKiX2BRo4p6eRlJy+WAsR
wW6Psj+EbRTENp7PT7fCylSYw7FYCS05mtsB8TYWvUEldOs9BfDQ/8lsiDsrVd5Tk+w==
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="XMcTH/d/";
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 41098606A333;
Fri, 4 Dec 2026 22:56:45 +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=XMcTH/d/
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796425004;
b=B2gfDswHDNmV7BsHepsftEbeKdM0Fj2HF/a10Hpxm47KxcEHQ9q8U4UcFCBbiRToiEUd
E2R8qQ8qDI/UdWzhn6SVFhRVlN8PlWhmUNGNzK1E/rRiXZsinZiXR7kUc5W7kyBM17aGw
81BBDx9YBrzDhgkFYdrsK0NROK9hrJr2g2oPfSU+OMbpMWWBZnK9a7EMc3z3eDbNm34i5
AW4wWMyEVky3IjSu3lMXUhChkWagROtlq8R6u+fPzSwiv2tHbDwwEZQGQJLrRSiWDCq3k
1asG7uV+xcri5hCb3/zcQpelUbwBdrGJEPMNEupnpaOnV0YR4+a87+Ot5YiNwAf5TDA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796425004;
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:MIME-Version:Content-Transfer-Encoding;
bh=tni4vlTMjlXKoDcAfyoUx2O2o30OFDLWW6FZclB6Z7k=;
b=nHqOve/BYppUHY8RhPjwrP17aZiBeBGuaIXm7p6kq7Fok3ETIzmFYHU9mB05w2sjfu5k
lSyU7jxkwKgiWlTIw1AhvpR1LmmK+dcE+a547OCTc5PiPsOJosofgaX34YBN/UZzavfA7
swoaeIyy6sbpwxEiYdxUXDB2aCVhkfKAnrZU+EKSQgKEXHkpHraAXJYNxmBQte6uxVJiB
kJMkthJMcwHTywsAam2RW2UAMYSjAfWWcQxcr64pvXryDBtb1Ov+e7TqpzRhlDYsNeafx
ky3nnYT4wCVd/Ouyw6hnL/0Fh4Uc3jLrin6FMFYVVgPC7gYTUfoMQUwkHxjVgw/Nx9A==
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="XMcTH/d/";
arc=none smtp.remote-ip=74.125.82.179
X-Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179])
(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 02FE9606A322
for <git@vger.kernel.org>; Fri, 4 Dec 2026 22:56:43 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 02FE9606A322
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-f179.google.com with SMTP id 5a478bee46e88-3874cf7625cso1828131eec.0
for <git@vger.kernel.org>; Fri, 04 Dec 2026 14:56:43 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796425003; x=1797029803; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=tni4vlTMjlXKoDcAfyoUx2O2o30OFDLWW6FZclB6Z7k=;
b=XMcTH/d/VkuciWw/JJB0qp7/uoytpGnbucIBEZepXUiTWm1Hh1h/fZewi94XWIAXo2
rSOuCjBpLaU2h2qpw2kzCW//1g6nDc0CdQHwQ9LgyGPQViTJxtJl2HP5l0scUySVc7T9
mO679vDhdMVdjIyqIsE8+pjGejxM4hezZlk80PLIziGo7//1gxxIzo0N9mzilOzYChR4
jhyAtxZqlF6oNu8NOed1MV/GYlgDb2hB+WKggaJB7lXOYjlrF9MtX9ndXaEFSrj7Dssq
3PY5hkh6wmeUuOsR60fCjCD/Z2kRi3EACYu+RXquiJZHF7+C00AE98hTqA7p6mSMDpbZ
CKqQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796425003; x=1797029803;
h=content-transfer-encoding:mime-version: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=tni4vlTMjlXKoDcAfyoUx2O2o30OFDLWW6FZclB6Z7k=;
b=MBuhacJT9Lwf3p9YiU5KexRzHpFgYWnO50Aeo+rNxpUSaEdlP5gvTOFDh99ncsO8lz
YGD1IYoee/TUilAjl8rxF+372VrUtvUG3p/7e6hXjA3IUkhDBstYq3lYR3T3t8sEV2Gx
Iv1QDHENsyfxAAluSLQ+Z/rGtYcoF82sESkPf6QyZ/Pou/45Qw7Mk4yX6KQVr7DLjAeQ
1FlpqtoBMadxzP/chWg5bh0aPOy/jdiNQ+Gm/UVfmXSi9ftOExsS5GsT4KHo4g4zKamo
GVTEO3WErwEoIBOQty9Db1F3AEqNFCplUtX64Fk/o8A0fMqb+VSz+0KNav9fQWM5kaTW
amKw==
X-Gm-Message-State: APuU4Z9pLeEC7FG4JiUNJIVzzUQMw1GE9hB7s657RoHf0jIE+zDT/cbB
qVE9apJYt0Y1pIreHweLBS/j4hGp4defedAUUjclC/ljgKxowPLvn6qDED9yjQ==
X-Gm-Gg: AZFdTZcXXritN9g3a2Byxfy/c7QjaFY3zKemmf4IY5NRf7kWsOH65cpQPRK1kM4ZzIk
Exp2LV550I7FIOq7eF66SZFTlOVB4kz9cxJVQY9CUnU6KFBZQgcZBiKade+krL6bgDxL+3aG7Wj
Zez2uxzu1u1yK7zVJFZJuWniFiJIWdl391O/CjgfgsmysGss0ux//9vlUjfoA8XteNse1lxiU4R
Tq15bVzFSSL92YjpLtkl03n50grnIsgfH81YX+883Uj/4IboHwadL6+pyXjdXCll4LDAvRCBK/I
pf62hprK+MXIbg9BofDSav+WA9yZeolY2V+/ho6LOgFIkPPHWLWP1U0LO5hb9bEI2kyJxYg69Ua
7zn8QOKMhgibZxfxluXmo/ITLs06N8A4kiQtSZ3h2fRH0obEzeUUSegaI/FH/MclQ7JeFngXZh1
dvnJTPV886GIR9Ib4Ue1uxdeFPRI3xnwha4zZX6Oz8xZQHn7N4VEyniuHJOEDbvtFuINtSLNZ4Y
NyEaGvJ2GA/WIVPQ59WJyimZgvw0uO0qO747ut5Y2TEGp66sHEHEcMO/uQkHveGilvxZe2vF5sz
NLNVK/D76iE+a/lpYZvX9qK756mhXTe5o5qhxMUF/S4VQf1K8/d+4mVB+gW6YULg0I1EuApUNw+
tN1PsYw+135VMKKXTkdGoMzhnlHN3pspiPDEzYLGU86xz
X-Received: by 2002:a05:693c:41d6:20b0:387:2d4d:596e with SMTP id 5a478bee46e88-387521e1bbamr3232368eec.38.1796425002894;
Fri, 04 Dec 2026 14:56:42 -0800 (PST)
X-Received: from localhost.localdomain ([2601:645:c100:ab8f:a453:914a:6bd1:2a12])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875220c35asm11717295eec.22.2026.12.04.14.56.42
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Fri, 04 Dec 2026 14:56:42 -0800 (PST)
X-Cc: Patrick Steinhardt <ps@pks.im>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
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