Merge branch 'nd/per-worktree-ref-iteration'
authorJunio C Hamano <gitster@pobox.com>
Tue, 13 Nov 2018 13:37:26 +0000 (22:37 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Nov 2018 13:37:26 +0000 (22:37 +0900)
The code to traverse objects for reachability, used to decide what
objects are unreferenced and expendable, have been taught to also
consider per-worktree refs of other worktrees as starting points to
prevent data loss.

* nd/per-worktree-ref-iteration:
git-worktree.txt: correct linkgit command name
reflog expire: cover reflog from all worktrees
fsck: check HEAD and reflog from other worktrees
fsck: move fsck_head_link() to get_default_heads() to avoid some globals
revision.c: better error reporting on ref from different worktrees
revision.c: correct a parameter name
refs: new ref types to make per-worktree refs visible to all worktrees
Add a place for (not) sharing stuff between worktrees
refs.c: indent with tabs, not spaces

1  2 
Documentation/git-worktree.txt
Documentation/gitrepository-layout.txt
builtin/fsck.c
builtin/reflog.c
path.c
refs.c
refs.h
revision.c
t/t1450-fsck.sh
worktree.c
worktree.h
index 5e986ce8aaf4a06e6ac21ca6266c8b7066d1a9d2,69d55f13502223c77c407c849f6089c8b5193112..cb86318f3e1b34e0eda5b9886fc934456434e7a8
@@@ -204,36 -204,35 +204,65 @@@ working trees, it can be used to identi
  you only have two working trees, at "/abc/def/ghi" and "/abc/def/ggg",
  then "ghi" or "def/ghi" is enough to point to the former working tree.
  
+ REFS
+ ----
+ In multiple working trees, some refs may be shared between all working
+ trees, some refs are local. One example is HEAD is different for all
+ working trees. This section is about the sharing rules and how to access
+ refs of one working tree from another.
+ In general, all pseudo refs are per working tree and all refs starting
+ with "refs/" are shared. Pseudo refs are ones like HEAD which are
+ directly under GIT_DIR instead of inside GIT_DIR/refs. There are one
+ exception to this: refs inside refs/bisect and refs/worktree is not
+ shared.
+ Refs that are per working tree can still be accessed from another
+ working tree via two special paths, main-worktree and worktrees. The
+ former gives access to per-worktree refs of the main working tree,
+ while the latter to all linked working trees.
+ For example, main-worktree/HEAD or main-worktree/refs/bisect/good
+ resolve to the same value as the main working tree's HEAD and
+ refs/bisect/good respectively. Similarly, worktrees/foo/HEAD or
+ worktrees/bar/refs/bisect/bad are the same as
+ GIT_COMMON_DIR/worktrees/foo/HEAD and
+ GIT_COMMON_DIR/worktrees/bar/refs/bisect/bad.
+ To access refs, it's best not to look inside GIT_DIR directly. Instead
+ use commands such as linkgit:git-rev-parse[1] or linkgit:git-update-ref[1]
+ which will handle refs correctly.
 +CONFIGURATION FILE
 +------------------
 +By default, the repository "config" file is shared across all working
 +trees. If the config variables `core.bare` or `core.worktree` are
 +already present in the config file, they will be applied to the main
 +working trees only.
 +
 +In order to have configuration specific to working trees, you can turn
 +on "worktreeConfig" extension, e.g.:
 +
 +------------
 +$ git config extensions.worktreeConfig true
 +------------
 +
 +In this mode, specific configuration stays in the path pointed by `git
 +rev-parse --git-path config.worktree`. You can add or update
 +configuration in this file with `git config --worktree`. Older Git
 +versions will refuse to access repositories with this extension.
 +
 +Note that in this file, the exception for `core.bare` and `core.worktree`
 +is gone. If you have them in $GIT_DIR/config before, you must move
 +them to the `config.worktree` of the main working tree. You may also
 +take this opportunity to review and move other configuration that you
 +do not want to share to all working trees:
 +
 + - `core.worktree` and `core.bare` should never be shared
 +
 + - `core.sparseCheckout` is recommended per working tree, unless you
 +   are sure you always use sparse checkout for all working trees.
 +
  DETAILS
  -------
  Each linked working tree has a private sub-directory in the repository's
Simple merge
diff --cc builtin/fsck.c
Simple merge
Simple merge
diff --cc path.c
Simple merge
diff --cc refs.c
Simple merge
diff --cc refs.h
Simple merge
diff --cc revision.c
Simple merge
diff --cc t/t1450-fsck.sh
Simple merge
diff --cc worktree.c
Simple merge
diff --cc worktree.h
Simple merge