From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179 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== 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== 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 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 ; Fri, 4 Dec 2026 22:56:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 02FE9606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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/ Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-3874cf7625cso1828131eec.0 for ; Fri, 04 Dec 2026 14:56:43 -0800 (PST) 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) 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) From: Aman Ganapathy To: git@vger.kernel.org Cc: Patrick Steinhardt Subject: [PATCH] mktree, bisect, remote: load the default config Date: Fri, 4 Dec 2026 14:56:41 -0800 Message-Id: <20261204225641.12294-1-amanganapathy@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) 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-Transfer-Encoding: 8bit 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 --- 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