• Duy Nguyen's avatar
    doc: outline how submodules work with multi worktrees · 07a84fe5
    Duy Nguyen authored
    This lays out the very first step of making multiple worktrees and
    submodules work together. No actual changes are here. And real changes
    are not even in the very next patches since they are cleanup and
    preparation patches.
    
    When a submodule is added to a superproject, the superproject's config
    file records info related to the submodule in its config file. The
    submodule's config file also has core.worktree to point back to the
    submodule worktree's location.
    
    Since config files are shared without extensions.worktreeConfig, adding
    a secondary superproject or submodule worktree will run into trouble [1].
    The problem could be solved with extensions.worktreeConfig and we keep
    per-worktree config in config.worktree files, both at superproject
    (submodule.*.*) and submodule (core.worktree) levels.
    
    The whole directory layout would look like this. This shows how
    multiple worktrees of a submodule or a supermodule are organized:
    
      .git/
        config                           contains shared submodule.*
        config.worktree                  contains submodule.sub1.*
                                         for the main worktree
        worktrees/
          super1/                   (1)
            config.worktree              submodule.sub1.* for super1
            modules/
              sub1/                 (2)
                config.worktree          contains core.worktree
                objects/            (3)
                worktrees/          (4)
                  wt1/
                  wt2/
          super2/                   (5)
            config.worktree              submodule.sub1.* for super2
            modules
              sub1/                 (6)
                config.worktree          contains core.worktree
                objects/            (7)
      super1/
        .git                     -> (1)
        sub1/
          .git                   -> (2)
        sub1-wt1/
          .git                   -> (4)/wt1
        sub1-wt2/
          .git                   -> (4)/wt2
      super2/
        .git                     -> (5)
        sub1/
          .git                   -> (6)
    
    This directory layout works, but not optimal. Submodule clones (inside
    the "modules" directory) are per-worktree. If you have two
    superproject worktrees that contain a submodule, you need space for
    _two_ clones, e.g. the object databases (3) and (7) are almost
    identical, but they are still duplicated.
    
    This is definitely not elegant. The tentative plan is to move the
    clones to a common tree like below. This is however just an idea and
    not implemented in this series.
    
      .git/
        config                           contains shared submodule.*
        objects/
        common/
          modules/
            sub1/                   (0)
              objects/              (shared)
              worktrees/
                super1/             (2)
                super1-wt1/         (4)/wt1
                super1-wt2/         (4)/wt2
                super2/             (6)
    	  common/
    	    modules/
    	      nested-sub/...
        worktrees/
          super1/                   (1)
            config.worktree              submodule.sub1.* for super1
          super2/                   (5)
            config.worktree              submodule.sub1.* for super2
    
    The subtree (0) is shared across all worktrees because it's inside
    "common/" directory. Once we keep the clone in a common place like
    this, the submodule's worktree can be created and managed with
    git-worktree[1].
    
    Another good point about this approach is we could finally safely
    allow "git worktree remove" to work with submodules. With current
    solution, removing $GIT_COMMON_DIR/worktrees/X directory means also
    removing potentially precious clones inside the "modules" subdir.
    
    But whether we can do this depends on:
    
    - if we need separate ref namespace for submodule on each worktree.
      Use cases that can share ref namespace will work best.
    
    - how does submodule's worktrees interact these worktrees
    
    - handling nested submodules can get very messy (or not?)
    
    This series does not attempt to implement subtree (0) at all. Once we
    get submodules and worktrees work well together (even wasteful of disk
    space), we can start thinking about absorbing clones back to common/
    
    [1] It's milder for secondary submodule worktree because core.worktree
        will not be shared (core.worktree by default is only visible to
        the main worktree). But then the second worktree cannot have its
        own core.worktree.
    07a84fe5
Name
Last commit
Last update
..
RelNotes Loading commit data...
config Loading commit data...
howto Loading commit data...
technical Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
CodingGuidelines Loading commit data...
Makefile Loading commit data...
SubmittingPatches Loading commit data...
asciidoc.conf Loading commit data...
asciidoctor-extensions.rb Loading commit data...
blame-options.txt Loading commit data...
build-docdep.perl Loading commit data...
cat-texi.perl Loading commit data...
cmd-list.perl Loading commit data...
config.txt Loading commit data...
date-formats.txt Loading commit data...
diff-format.txt Loading commit data...
diff-generate-patch.txt Loading commit data...
diff-options.txt Loading commit data...
doc-diff Loading commit data...
docbook-xsl.css Loading commit data...
docbook.xsl Loading commit data...
everyday.txto Loading commit data...
fetch-options.txt Loading commit data...
fix-texi.perl Loading commit data...
git-add.txt Loading commit data...
git-am.txt Loading commit data...
git-annotate.txt Loading commit data...
git-apply.txt Loading commit data...
git-archimport.txt Loading commit data...
git-archive.txt Loading commit data...
git-bisect-lk2009.txt Loading commit data...
git-bisect.txt Loading commit data...
git-blame.txt Loading commit data...
git-branch.txt Loading commit data...
git-bundle.txt Loading commit data...
git-cat-file.txt Loading commit data...
git-check-attr.txt Loading commit data...
git-check-ignore.txt Loading commit data...
git-check-mailmap.txt Loading commit data...
git-check-ref-format.txt Loading commit data...
git-checkout-index.txt Loading commit data...
git-checkout.txt Loading commit data...
git-cherry-pick.txt Loading commit data...
git-cherry.txt Loading commit data...
git-citool.txt Loading commit data...
git-clean.txt Loading commit data...
git-clone.txt Loading commit data...
git-column.txt Loading commit data...
git-commit-graph.txt Loading commit data...
git-commit-tree.txt Loading commit data...
git-commit.txt Loading commit data...
git-config.txt Loading commit data...
git-count-objects.txt Loading commit data...
git-credential-cache--daemon.txt Loading commit data...
git-credential-cache.txt Loading commit data...
git-credential-store.txt Loading commit data...
git-credential.txt Loading commit data...
git-cvsexportcommit.txt Loading commit data...
git-cvsimport.txt Loading commit data...
git-cvsserver.txt Loading commit data...
git-daemon.txt Loading commit data...
git-describe.txt Loading commit data...
git-diff-files.txt Loading commit data...
git-diff-index.txt Loading commit data...
git-diff-tree.txt Loading commit data...
git-diff.txt Loading commit data...
git-difftool.txt Loading commit data...
git-fast-export.txt Loading commit data...
git-fast-import.txt Loading commit data...
git-fetch-pack.txt Loading commit data...
git-fetch.txt Loading commit data...
git-filter-branch.txt Loading commit data...
git-fmt-merge-msg.txt Loading commit data...
git-for-each-ref.txt Loading commit data...
git-format-patch.txt Loading commit data...
git-fsck-objects.txt Loading commit data...
git-fsck.txt Loading commit data...
git-gc.txt Loading commit data...
git-get-tar-commit-id.txt Loading commit data...
git-grep.txt Loading commit data...
git-gui.txt Loading commit data...
git-hash-object.txt Loading commit data...
git-help.txt Loading commit data...
git-http-backend.txt Loading commit data...
git-http-fetch.txt Loading commit data...
git-http-push.txt Loading commit data...
git-imap-send.txt Loading commit data...
git-index-pack.txt Loading commit data...
git-init-db.txt Loading commit data...
git-init.txt Loading commit data...
git-instaweb.txt Loading commit data...
git-interpret-trailers.txt Loading commit data...
git-log.txt Loading commit data...
git-ls-files.txt Loading commit data...
git-ls-remote.txt Loading commit data...
git-ls-tree.txt Loading commit data...
git-mailinfo.txt Loading commit data...
git-mailsplit.txt Loading commit data...
git-merge-base.txt Loading commit data...
git-merge-file.txt Loading commit data...
git-merge-index.txt Loading commit data...
git-merge-one-file.txt Loading commit data...
git-merge-tree.txt Loading commit data...
git-merge.txt Loading commit data...
git-mergetool--lib.txt Loading commit data...
git-mergetool.txt Loading commit data...
git-mktag.txt Loading commit data...
git-mktree.txt Loading commit data...
git-multi-pack-index.txt Loading commit data...
git-mv.txt Loading commit data...
git-name-rev.txt Loading commit data...
git-notes.txt Loading commit data...
git-p4.txt Loading commit data...
git-pack-objects.txt Loading commit data...
git-pack-redundant.txt Loading commit data...
git-pack-refs.txt Loading commit data...
git-parse-remote.txt Loading commit data...
git-patch-id.txt Loading commit data...
git-prune-packed.txt Loading commit data...
git-prune.txt Loading commit data...
git-pull.txt Loading commit data...
git-push.txt Loading commit data...
git-quiltimport.txt Loading commit data...
git-range-diff.txt Loading commit data...
git-read-tree.txt Loading commit data...
git-rebase.txt Loading commit data...
git-receive-pack.txt Loading commit data...
git-reflog.txt Loading commit data...
git-remote-ext.txt Loading commit data...
git-remote-fd.txt Loading commit data...
git-remote-helpers.txto Loading commit data...
git-remote.txt Loading commit data...
git-repack.txt Loading commit data...
git-replace.txt Loading commit data...
git-request-pull.txt Loading commit data...
git-rerere.txt Loading commit data...
git-reset.txt Loading commit data...
git-rev-list.txt Loading commit data...
git-rev-parse.txt Loading commit data...
git-revert.txt Loading commit data...
git-rm.txt Loading commit data...
git-send-email.txt Loading commit data...
git-send-pack.txt Loading commit data...
git-sh-i18n--envsubst.txt Loading commit data...
git-sh-i18n.txt Loading commit data...
git-sh-setup.txt Loading commit data...
git-shell.txt Loading commit data...
git-shortlog.txt Loading commit data...
git-show-branch.txt Loading commit data...
git-show-index.txt Loading commit data...
git-show-ref.txt Loading commit data...
git-show.txt Loading commit data...
git-stage.txt Loading commit data...
git-stash.txt Loading commit data...
git-status.txt Loading commit data...
git-stripspace.txt Loading commit data...
git-submodule.txt Loading commit data...
git-svn.txt Loading commit data...
git-symbolic-ref.txt Loading commit data...
git-tag.txt Loading commit data...
git-tools.txt Loading commit data...
git-unpack-file.txt Loading commit data...
git-unpack-objects.txt Loading commit data...
git-update-index.txt Loading commit data...
git-update-ref.txt Loading commit data...
git-update-server-info.txt Loading commit data...
git-upload-archive.txt Loading commit data...
git-upload-pack.txt Loading commit data...
git-var.txt Loading commit data...
git-verify-commit.txt Loading commit data...
git-verify-pack.txt Loading commit data...
git-verify-tag.txt Loading commit data...
git-web--browse.txt Loading commit data...
git-whatchanged.txt Loading commit data...
git-worktree.txt Loading commit data...
git-write-tree.txt Loading commit data...
git.txt Loading commit data...
gitattributes.txt Loading commit data...
gitcli.txt Loading commit data...
gitcore-tutorial.txt Loading commit data...
gitcredentials.txt Loading commit data...
gitcvs-migration.txt Loading commit data...
gitdiffcore.txt Loading commit data...
giteveryday.txt Loading commit data...
gitglossary.txt Loading commit data...
githooks.txt Loading commit data...
gitignore.txt Loading commit data...
gitk.txt Loading commit data...
gitmodules.txt Loading commit data...
gitnamespaces.txt Loading commit data...
gitremote-helpers.txt Loading commit data...
gitrepository-layout.txt Loading commit data...
gitrevisions.txt Loading commit data...
gitsubmodules.txt Loading commit data...
gittutorial-2.txt Loading commit data...
gittutorial.txt Loading commit data...
gitweb.conf.txt Loading commit data...
gitweb.txt Loading commit data...
gitworkflows.txt Loading commit data...
glossary-content.txt Loading commit data...
howto-index.sh Loading commit data...
i18n.txt Loading commit data...
install-doc-quick.sh Loading commit data...
install-webdoc.sh Loading commit data...
line-range-format.txt Loading commit data...
lint-gitlink.perl Loading commit data...
mailmap.txt Loading commit data...
manpage-1.72.xsl Loading commit data...
manpage-base-url.xsl.in Loading commit data...
manpage-base.xsl Loading commit data...
manpage-bold-literal.xsl Loading commit data...
manpage-normal.xsl Loading commit data...
manpage-quote-apos.xsl Loading commit data...
manpage-suppress-sp.xsl Loading commit data...
merge-options.txt Loading commit data...
merge-strategies.txt Loading commit data...
pretty-formats.txt Loading commit data...
pretty-options.txt Loading commit data...
pull-fetch-param.txt Loading commit data...
rev-list-options.txt Loading commit data...
revisions.txt Loading commit data...
sequencer.txt Loading commit data...
texi.xsl Loading commit data...
transfer-data-leaks.txt Loading commit data...
urls-remotes.txt Loading commit data...
urls.txt Loading commit data...
user-manual.conf Loading commit data...
user-manual.txt Loading commit data...