From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.146 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795941180; b=CWjnGfN3ycw2kcM1PSvVYgRC06RMGkiDfIZuG983Zj1thqPTZJzpzOBL5IQTzwhXLITC fcezuKOK6rhfXsYC9I7oYEtO3Ksn5OEqhQwhur9hvn+/CUKchMcwI9fQblRkX9wAss+rX w77Ev0XM1DM7Ht4uNo2fuMiuZLc/ydvPYyxS7iTjGVFTQ7F+2oOpQvCg0dlmgdunUdIi5 HKVBz7WzbBol6LKnewdJuZnquqIOBdAMUGw5GAnhUfsp9xaI0S2h3p0i7pqCvQvdAHt7g e8rzGLsE6xINAXLs5Stuv+4ALWiRGReFoL3P80zQaEGnTywcQngXn5h4SaMoF/obaOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795941180; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: User-Agent:MIME-Version:Content-Type; bh=1JUitJxSI6HVtx5jgtiw+kiIPsIvwxov/o0e44aUdp0=; b=vyHWFea0ipyuWqxuiv123Q5tbDVQul6XK/7nnWEYhB0g/S+yjHKZKgmUErNmZv1rCVUS 2T4+psyRy56sljQ1MYQap3rX1A3AZ5vn8PLobLN0389/EM9l7VUpBGMY4xiWKz9JkUjYB m72Or04WBGqHxk5tWoMIl2+jnwYgcpRm83g7IhfaGXaVS6RGAMT2eg/gJDL74H++1buxR LDwm1nFtiA7ogZsOMmSUovN3spx4ilfllBTmVXO5ER6jT4f0/8Fh9rpb2WbQrY1Ubyde2 CGUGTBqgyhJMraIUJk7ipwKAA6PN+mUnHbiFE+LEm+2UXK/lu0N6XYcW7tZmxkSxYjA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=JqYpBh1e; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=1tRrwgoz; arc=none smtp.remote-ip=202.12.124.146 Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26369606A31C for ; Sun, 29 Nov 2026 08:32:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26369606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=JqYpBh1e; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=1tRrwgoz Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id 77D051D004FD for ; Sun, 29 Nov 2026 03:32:58 -0500 (EST) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-01.internal (MEProxy); Sun, 29 Nov 2026 03:32:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1795941178; x=1796027578; bh=1JUitJxSI6 HVtx5jgtiw+kiIPsIvwxov/o0e44aUdp0=; b=JqYpBh1e1M6nYu93J1NOBssnA4 o8Gt0N0257J0CKpfzNI5E9clSFmtl/rDKjGRFitI+MM4Wtd7uz/ArNv7cRues9mK uS7kVuajDd9dRVu9m1MK8JeDy80mUPPbKJtmBuFxwMHhbKeP+xLXVBl6PVQ5IMgb 4T6DVP804t6jh/t27cmM7+Iu5mpyM3XXNvD9lrJsW9xmVFJTLzWYia0DSZfXs18E g/NJOCXdDfXRKKLSJ6nJAsWKeZUzyXaVvmZxUY/cEnTkUz0qD1HtfH4H4JHr0/nD fDym5diBtY0AOGgEq2a7eulgWaq+JhgZEZmUm/tft3oD17kLYgMTOr7XJ5cQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1795941178; x=1796027578; bh=1JUitJxSI6HVtx5jgtiw+kiIPsIvwxov/o0 e44aUdp0=; b=1tRrwgozT/8llnF5Ym6UVyHg5XZmcjMVrJg8RTetFUWKS7LLULW 2cRbkTLsDfZzrbbQuHg10S8BWI53bpIlq0OcLosnoDobYBuHo8PpmUnradVI3uHd qFleFDeSFUepGfMigcFKMS5NpFgJXhIbMZxj4avSKCToXFUx59bw2FhT8jBfyU9D 12Xs5NO/iv+xwPbwxEd0ytfyKi4Qu1nN3beGmutopEkw8AVwLLlwKO8GfIO05YWI un1nMFdpFSKJRnXQ3wyqSCxzw3Yat82iZx2sUXqJHFKc8lpL6gikqCWtJm9lOkN+ KTrEi3lkKKOqTdqkQr5ESnz69DXiDzC7nKQ== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pobox.com a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1795941178; d=pobox.com; mf=PGdpdHN0ZXJAcG9ib3guY29tPg==; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm2:rsa-sha256:dt1UAvLf9ByuSR9CJzywZ3w0LRcgLuhwx84EqlG+EpLRD7e 4c5umYIDzZq2nnCXDn6v7hjEPW6uMwVSi6WxVsYBOi4S7zFYfVBJJqNUAcz+4sJU CuAkbNq2s/TB2hTKJq6cRxnC2uwJ0aC+Is+YP4AQJ30XSwAsbOrntcoiM4KmKjC9 LgZszwotL/Bz8U9AHu6230Fqx+ksp6+o8iLA5v/c9ALqwQ5hIt9kJYcUOwQeL8MS g4SpYN8g+E9E0UXkm8iDeGl2gGdV/sAqZnWV6c/AE2IpWJ4irV+QioVchYXylECK Ywi02YuyAS1BI7TAEStzTfZ+HpNw7RHRw5h9+eA==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id, mime-version,references,subject,to,user-agent; Message-Instance: m=1; h=sha256:ZBdj2E6rGO1R2XSNFr7lKq5uFQKuTLn4IISCSPA1c64=:METkMkFiUkB3WRRkcJKMD43UtTAPck5+WpYegVC8kwc=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGanY9UdmRomvuBM+oCT/Wv6bJqWqIAWOe2dV8KZ345bI3m94PlbqEcNGdZKpoQP3 TTLa9sGtLW6jqvj2tU/LgxrsrDpuEYkeN7qI5L3Y4WNoBmIzJ3Q7GHZDzUHXlxHNimO9rJ BFNjFW+o/ae4T4R9S3gv+Nm7wmBC/BoeVuQIV+Y51mFcz70EW5vzVw9lKjBCQYyDCDER0K VIsmxE9s901mtmuZEzgqGYJo7enB7qX8+IzJ2S4zHcGelJKcqemZWwjT8tJGy9H0ruLs43 /N1IiPJohs7O2+oXQPRDfjXQQZUm/qeaLfwX9fMfQiCqmmTyBo+3UO4P5HvPp7ycGUs4BE 6h9DLRcEDLDmJUotznrYws2LB9muC+bQHWvg69sL90JWNKJ2dJLJ8swhqkJSiRrj+EDWAf djpX4+fveJCkGP0/j2JEoNq25gmKSAb2O2AhELJvKwaiD00ABpyZIbv7IDOCdXmqNfyJfb ovQ2JbHVzu/BDunwqD2Wq89GF1CAIDSFjz4N51QXamuUAx7vN3hvRqrmPWdVqHpD1pyqOJ btPHLTtUzPd+UQBK+HjJaGzNJuL3dOFffM8rP+fXIYoswgzrC0e/anxlmQyiezBHbwov6W PPDkOsUwr/smcMQSEaSb6X84tZxNdd7Xc/xzG8F9hQuZLtc/VHWGcIQ/DutA X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 29 Nov 2026 03:32:57 -0500 (EST) From: Junio C Hamano To: "Yoichi NAKAYAMA via GitGitGadget" Cc: git@vger.kernel.org, Yoichi NAKAYAMA Subject: Re: [PATCH v3 4/4] submodule init: copy submodule..gitdir to config.worktree In-Reply-To: <3e2c1612988ea1bc74b94a2cfc17e24dfd41ca3e.1795903557.git.gitgitgadget@gmail.com> (Yoichi NAKAYAMA via GitGitGadget's message of "Sat, 28 Nov 2026 22:05:57 +0000") References: <3e2c1612988ea1bc74b94a2cfc17e24dfd41ca3e.1795903557.git.gitgitgadget@gmail.com> Date: Sun, 29 Nov 2026 00:32:56 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) 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-Type: text/plain "Yoichi NAKAYAMA via GitGitGadget" writes: > +static bool submodule_git_dir_matches_current_worktree(const char *gitdir) > +{ > + struct strbuf tmp = STRBUF_INIT; > + struct strbuf submodule = STRBUF_INIT; > + char *super; > + bool matches; > + > + if (is_absolute_path(gitdir)) > + strbuf_addstr(&submodule, gitdir); > + else if (!repo_worktree_path_append(the_repository, &submodule, > + "%s", gitdir)) > + return false; > + > + if (strbuf_normalize_path(&submodule)) { > + strbuf_release(&submodule); > + return false; > + } > + > + super = real_pathdup(repo_get_git_dir(the_repository), 1); > + matches = starts_with(relative_path(submodule.buf, super, &tmp), > + "modules/"); Isn't there still a symlink asymmetry here? While 'super' now resolves symlinks via real_pathdup(), 'submodule' only goes through strbuf_normalize_path(), which performs purely lexical normalization without calling lstat() or readlink(). Suppose a repository 'repo' has a symlink 'repo-link' pointing to it, and an older Git (before [PATCH 2/4]) wrote an absolute path through the symlink into the repository config, such as "/path/to/repo-link/.git/modules/sub1_custom" (or a value containing a symlinked parent directory like /tmp or /var). When the user later enables extensions.worktreeConfig and runs "git submodule init" in 'repo': 1. strbuf_normalize_path() leaves the symlink component in 'submodule.buf' unresolved, so it stays "/path/to/repo-link/.git/modules/sub1_custom". 2. real_pathdup() resolves 'super' to "/path/to/repo/.git". 3. relative_path() compares the two strings byte-by-byte, diverges at 'repo-link' vs 'repo', and returns "../../repo-link/.git/modules/sub1_custom" instead of "modules/sub1_custom". 4. submodule_git_dir_matches_current_worktree() then returns false, emitting the mismatch warning and overwriting the custom setting in config.worktree with ".git/modules/sub1". The new test in t7425 uses "pwd -P", which may hide this case. Using strbuf_realpath_forgiving(&submodule, submodule.buf, 0) instead of (or before) strbuf_normalize_path(&submodule) keeps both sides canonicalized even when the final submodule gitdir directory does not exist yet, avoids collapsing "/.." lexically before resolving the symlink, and lets invalid paths return false cleanly. > +static const char submodule_mismatch_warning[] = N_( > +"config '%s' exists but was not copied to the worktree config because " > +"it does not point to a gitdir for the current worktree. If you want " > +"to keep using this setting, copy it to the worktree config." > +); The sentence "If you want to..." feels a bit odd, doesn't it? "git submodule init" just wrote a fallback setting into config.worktree and sharing another worktree's gitdir is usually not what you want to do. Saying "If you want to use this setting here, set it in the worktree config.' or dropping that sentence altogether may make the message less confusing. I dunno. > ... > + if (!matches || > + validate_submodule_git_dir(tmp, submodule_name)) { > + if (!matches) > + warning(submodule_mismatch_warning, key); You'd need _() around submodule_mismatch_warning don't you?