Skip to content

pr-2306/yoichi/submodule-with-worktree-v3

tagged this 28 Nov 22:05
When using multiple worktrees, submodule settings stored in the repository
config are shared between all worktrees, even when they need to differ.

For example, different branches may use different URLs for the same
submodule. More importantly, sharing submodule.<name>.gitdir causes
submodule worktrees to share the same HEAD and index, even when the
corresponding superproject worktrees record different commits for the
submodule.

This series makes submodule settings worktree-specific when
extensions.worktreeConfig is enabled. It also keeps submodule.<name>.gitdir
relative for linked worktrees, so it continues to work when the worktree is
moved along with the main worktree.

Included commits:

 * [1/4] Keep submodule.<name>.gitdir relative for linked worktrees.
 * [2/4] Resolve symlinks in submodule.<name>.gitdir.
 * [3/4] Store submodule settings in the worktree config when
   extensions.worktreeConfig is enabled.
 * [4/4] Make git submodule init copy an existing gitdir setting to the
   current worktree config only when it belongs to that worktree.

Changes in v3
=============

 * [1/4] Copy the path early, as relative_path may continue to use the
   provided buffer
 * [2/4] Add new commit to resolve symlinks in submodule.<name>.gitdir value
 * [3/4] Handle duplicate submodule.<name>.gitdir on 'git worktree add'
 * [3/4] Add more explanations
 * [4/4] Resolve symlinks in submodule_git_dir_matches_current_worktree()

Changes in v2
=============

 * Update the cover letter to better explain the problems this series
   addresses.
 * [1/3] Copy the string returned by worktree_git_path() early.
 * [2/3] Expand the explanation in the commit message for why the gitdir
   config is excluded from worktree add.
 * [3/3] Explain the case where the repository config contains a gitdir
   setting for another worktree, and warn when the setting is not copied.

Included commits:

 * [1/3] Keep submodule.<name>.gitdir relative for linked worktrees.
 * [2/3] Store submodule settings in the worktree config when
   extensions.worktreeConfig is enabled.
 * [3/3] Make git submodule init copy an existing gitdir setting to the
   current worktree config only when it belongs to that worktree.

Yoichi NAKAYAMA (4):
  submodule init: make submodule.<name>.gitdir relative for worktrees
  submodule init: resolve symlinks in submodule.<name>.gitdir
  submodule: store settings in worktree config when enabled
  submodule init: copy submodule.<name>.gitdir to config.worktree

 Documentation/config/extensions.adoc       |   9 +
 Documentation/config/submodule.adoc        |  14 +-
 Documentation/gitsubmodules.adoc           |  26 ++-
 builtin/submodule--helper.c                | 211 ++++++++++++++++-----
 builtin/worktree.c                         |  23 +++
 t/t2405-worktree-submodule.sh              | 157 +++++++++++++++
 t/t7425-submodule-gitdir-path-extension.sh | 147 +++++++++++++-
 7 files changed, 530 insertions(+), 57 deletions(-)

base-commit: acba8bf9753134d9bde89f94369f775838a8c5fe

Submitted-As: https://lore.kernel.org/git/pull.2306.v3.git.1795903557.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2306.git.1794484985.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2306.v2.git.1795273853.gitgitgadget@gmail.com
Assets 2
Loading