From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796244342; b=CZIz2v6J8WLp8D1Zc4rmQ/CLaLaGqtcCjUf9S7cbDgP6IXptv9TF/6qkkrCOEqcO7zQ7 skFg3fCGsKkbd1vxfVkGjqG/hmdOaUKK2iZemYjWMBuoGu8FZY6zolFz4K2kCC6Gc4gPJ VsAnciXxnfR8cKlQI1yHbee5jgk3DflEGvEAXFwGSWel0RC3pABRYWEFZyJyN0AJ06F1y eQzbcil5e/3yMO/HSluS6piUF83Z8DXukbzLAcvimU3PmW+W5yQBX+jpxzJgvvnNPW+rY OjNIbGJaFUStWvvmorzbCF5OWMB8TZL3cVKCFNpchNMZxubNC/eiQcjWB7UMFpyf9VA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796244342; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-Id:From:Date: Subject:Fcc:Content-Type:Content-Transfer-Encoding:MIME-Version:To: Cc; bh=VL0osZh35rTMV+iEUmI2Ju4SJX94ycppN9yxKZ0zo+4=; b=pdSYKqDFAIfbiXjMCv7BWFvqOUI6adahvYlU+dMPU6GL4YgPa4mEGloBgjWcRRqNjqfL UrN4ihoGFReJqoKdTL8WnctiiQ8kOmYGqa+swjYGxsafd34SPAn+t6NRm6/4uI+wqXtET RJ5w4NBmGI1gZoaWDt2fiUhJucc+MBvN7/FHBTwiTBerKJoM6eLtLSzVcehcwjhE98bz9 Pycl6Tf1+UPbsCAxPNS0GL6IVQLc9QDgqkZG99st2snmTIeNfFWAYOnOsM5lqbf4e286+ Jr0IixMw36rTAGExYTdOqhF7AWzzxD61L+S0y7H5qG2D2wNn0+Lj3/0GGLbA+TQOa0g== 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=F0eicQhx; arc=none smtp.remote-ip=209.85.215.178 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 27905606A333 for ; Wed, 2 Dec 2026 20:45:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 27905606A333 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=F0eicQhx Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-cdb1199bfd8so6447960a12.1 for ; Wed, 02 Dec 2026 12:45:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796244341; x=1796849141; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:content-type:fcc :subject:date:from:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=VL0osZh35rTMV+iEUmI2Ju4SJX94ycppN9yxKZ0zo+4=; b=F0eicQhxhUkDrOvttZW5+RP73/niHENau9ESiQvojb9xYW/pBHQ8KnsJ24RaLmezSh eqzUbGhg84XKLP3PDUvenng3h5CXnZzWLF1NVZwZRkZU0KT9Y8u2QuUg9MMb1oriv3Vk P7wtcPIe+hxPeUIU14bNFHFOh6h+JNp4AOonJhwHDirtDjpNXju9yEdLNUzO37YT4PFs ZU8lXKmxu0lsbBKTPP7Cyibi7Picugq/vP6yhAQA7I6bTAN4rtLL2pWtG3y5aEHko9Yp 0Sc9AtRcuqxBd0Nw3lOjywUJ/Y3vcEL5Rh317age5iag0BB2I1ZW8qeuzfDbnwmWHRuV 2vqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796244341; x=1796849141; h=cc:to:mime-version:content-transfer-encoding:content-type:fcc :subject:date:from:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=VL0osZh35rTMV+iEUmI2Ju4SJX94ycppN9yxKZ0zo+4=; b=eBgzZX6nVabcVvBd4yDDgxqQK11YiwqtXDrw24Hc8zPHbmfMXY8c7Ci0Yx6i+3ZRXh idih+1NSfzIX3d4BQALiRpckxilr2b4hXeTPUqTswRfKsk1mDhtMoyhGqThWbYIvmR9y Ajh+BRCLk6dJDo0EzWWtaKbW+PdwAToD1hDqYBCSSkZPQ4Bv6aHMzUSQTzkRU/uJ0IWV ugZAIzz9grfBOKsbKC/dmQpB767VwYLb/1eIqrF5axX0YzskFvH3GXw+BWQ+cRTmq0JQ AYOjE6t+IL9u2vg5wZ5BiLePpIYlnESBmrEXVW5jLlTRiKn1drxYExh3uFTG4vaBeHxQ e2lA== X-Gm-Message-State: APuU4Z91O4pAU5DDnM85JN1X3WsAi8nEKP3DXGnMR0xG97NaJYCU34bu qumArWqefEnek7Sr68ij4DtXgCNDp6IuC8vozRex6NU6PyR7VaPXayXGKBiv/g== X-Gm-Gg: AZFdTZdHAssLc6bF9SCzIRkk1qV5u3YMCuCu3wPDhZ07ociU86gR93zL5ny9tLRzQYP oHPMLWyd7I0/RAdRSUpp8vjY5FMNB7F+afTcACM0gLyMX9bc/X0Ss8hHEiouj1tlYGWbV691rna li/V2J/GvvEgAz4XTujPbmuWZBBxo94WCXOJiow0sa2BHREXN0rSJ9K5J9rLS+/nWiapS95GLLj xFTI/w5F2Ynb9d0JRUYQY6AjKuch05Db1sdQyUyhHcro0jRBVXbHj8eRul9rv8AZMxNwFB7hCYb ljxsJtINq2/c14Oy/UXL0wPdejKgMHd9XTTT24yIHFC5ugqMxNqCFeP7uxddbBP0bNhfOAH0pQb hzBk+X50Y64vMyJ0AC1PecwujMLIqTlI/eNjCbXy1FJ4jUl4iBcrzoglECWVYwWYKol9LReajf5 MxvhMu4q4JNTmdZ/9LqIsJnndph6iEOWwJdioq/TS8YYH2l4VkJw+YMBHGTB0e2HylnbntQCfkt VytR0GSxLYL57qpJIRrUwwhWolhFbCYjFrT4yQLLajQ6fgpItOymIijW/5BLmcQbeW27GJEcxZW awcy/JThSnTU7a/+cjvZkswk/HG5ZJAJkw== X-Received: by 2002:a17:90a:d2c7:b0:3b3:fe22:273d with SMTP id 98e67ed59e1d1-3b41c95b0cdmr39074055a91.41.1796244341240; Wed, 02 Dec 2026 12:45:41 -0800 (PST) Received: from [127.0.0.1] ([20.64.223.102]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c7a9c6f9sm750617a91.17.2026.12.02.12.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 12:45:40 -0800 (PST) Message-Id: From: "Daniel Fox via GitGitGadget" Date: Wed, 02 Dec 2026 20:45:40 +0000 Subject: [PATCH] clone: pass work tree to repack child of --dissociate Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 To: git@vger.kernel.org Cc: Daniel Fox , Daniel Fox From: Daniel Fox After "git clone --dissociate" copies the borrowed objects, dissociate_from_references() runs "git repack -a -d" in a child process. init_db() exports GIT_DIR, so the child inherits it. GIT_WORK_TREE is not exported. With GIT_DIR set and no GIT_WORK_TREE, the child treats its current directory as the top of the work tree. That directory is the one clone was run from, which is usually the parent of the new work tree. Repack itself does not care about the work tree, but it reads the index. When core.fsmonitor is enabled, reading the index can start the fsmonitor daemon implicitly. That daemon then watches the wrong directory and never sees the cookie files that clients create in the real work tree. As a result, every fsmonitor query in the new clone waits for the cookie timeout. When we have a work tree, export it to the child as GIT_WORK_TREE. Signed-off-by: Daniel Fox --- clone: pass work tree to repack child of --dissociate Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2346%2Fdanudey%2Ffsmonitor-clone-dissociate-worktree-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2346/danudey/fsmonitor-clone-dissociate-worktree-v1 Pull-Request: https://github.com/gitgitgadget/git/pull/2346 builtin/clone.c | 11 +++++++++++ t/t7527-builtin-fsmonitor.sh | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/builtin/clone.c b/builtin/clone.c index ac40250d25..f10f95e017 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -851,6 +851,17 @@ static void dissociate_from_references(void) cmd.git_cmd = 1; cmd.no_stdin = 1; + /* + * We export GIT_DIR but not GIT_WORK_TREE, so without this + * the child would treat our cwd (the parent of the new + * work tree) as its work tree. That matters because + * "repack" reads the index, which can auto-start the + * fsmonitor daemon, and it would then watch the wrong + * directory. + */ + if (the_repository->worktree) + strvec_pushf(&cmd.env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, + the_repository->worktree); strvec_pushl(&cmd.args, "repack", "-a", "-d", NULL); if (run_command(&cmd)) die(_("cannot repack to clean up")); diff --git a/t/t7527-builtin-fsmonitor.sh b/t/t7527-builtin-fsmonitor.sh index 86195770e9..a49511945b 100755 --- a/t/t7527-builtin-fsmonitor.sh +++ b/t/t7527-builtin-fsmonitor.sh @@ -304,6 +304,30 @@ test_expect_success MINGW,SHORTNAMES 'implicit daemon stop (rename GIT~2)' ' verify_implicit_shutdown test_implicit_1s2 ' +test_expect_success 'clone --dissociate starts daemon on the new work tree' ' + test_when_finished "stop_daemon_delete_repo dissociate/clone; rm -rf dissociate dissociate.trace" && + + git init dissociate/src && + test_commit -C dissociate/src file && + git clone dissociate/src dissociate/ref && + + # "--dissociate" runs "git repack" in a child process, which + # reads the index and so implicitly starts the daemon. That + # daemon must watch the new work tree, not the directory clone + # was run from; otherwise it never sees its own cookie files + # and every query waits for the cookie timeout. + ( + cd dissociate && + GIT_TRACE_FSMONITOR="$TRASH_DIRECTORY/dissociate.trace" && + export GIT_TRACE_FSMONITOR && + git -c core.fsmonitor=true clone --reference ref --dissociate \ + "file://$TRASH_DIRECTORY/dissociate/src" clone && + git -C clone fsmonitor--daemon status && + test-tool -C clone fsmonitor-client query --token 0 >/dev/null + ) && + test_grep ! "cookie_wait timed out" dissociate.trace +' + test_expect_success 'cannot start multiple daemons' ' test_when_finished "stop_daemon_delete_repo test_multiple" && base-commit: 03b41523c576f26ad34085378717a0c1b287470f -- gitgitgadget