diff options
Diffstat (limited to 'docs/internal-fs-layout.md')
| -rw-r--r-- | docs/internal-fs-layout.md | 263 |
1 files changed, 263 insertions, 0 deletions
diff --git a/docs/internal-fs-layout.md b/docs/internal-fs-layout.md new file mode 100644 index 00000000..af6a4523 --- /dev/null +++ b/docs/internal-fs-layout.md | |||
| @@ -0,0 +1,263 @@ | |||
| 1 | # Repo internal filesystem layout | ||
| 2 | |||
| 3 | A reference to the `.repo/` tree in repo client checkouts. | ||
| 4 | Hopefully it's complete & up-to-date, but who knows! | ||
| 5 | |||
| 6 | *** note | ||
| 7 | **Warning**: | ||
| 8 | This is meant for developers of the repo project itself as a quick reference. | ||
| 9 | **Nothing** in here must be construed as ABI, or that repo itself will never | ||
| 10 | change its internals in backwards incompatible ways. | ||
| 11 | *** | ||
| 12 | |||
| 13 | [TOC] | ||
| 14 | |||
| 15 | ## .repo/ layout | ||
| 16 | |||
| 17 | All content under `.repo/` is managed by `repo` itself with few exceptions. | ||
| 18 | |||
| 19 | In general, you should not make manual changes in here. | ||
| 20 | If a setting was initialized using an option to `repo init`, you should use that | ||
| 21 | command to change the setting later on. | ||
| 22 | It is always safe to re-run `repo init` in existing repo client checkouts. | ||
| 23 | For example, if you want to change the manifest branch, you can simply run | ||
| 24 | `repo init --manifest-branch=<new name>` and repo will take care of the rest. | ||
| 25 | |||
| 26 | * `config`: Per-repo client checkout settings using [git-config] file format. | ||
| 27 | * `.repo_config.json`: JSON cache of the `config` file for repo to | ||
| 28 | read/process quickly. | ||
| 29 | |||
| 30 | ### repo/ state | ||
| 31 | |||
| 32 | * `repo/`: A git checkout of the repo project. This is how `repo` re-execs | ||
| 33 | itself to get the latest released version. | ||
| 34 | |||
| 35 | It tracks the git repository at `REPO_URL` using the `REPO_REV` branch. | ||
| 36 | Those are specified at `repo init` time using the `--repo-url=<REPO_URL>` | ||
| 37 | and `--repo-rev=<REPO_REV>` options. | ||
| 38 | |||
| 39 | Any changes made to this directory will usually be automatically discarded | ||
| 40 | by repo itself when it checks for updates. If you want to update to the | ||
| 41 | latest version of repo, use `repo selfupdate` instead. If you want to | ||
| 42 | change the git URL/branch that this tracks, re-run `repo init` with the new | ||
| 43 | settings. | ||
| 44 | |||
| 45 | * `.repo_fetchtimes.json`: Used by `repo sync` to record stats when syncing | ||
| 46 | the various projects. | ||
| 47 | |||
| 48 | ### Manifests | ||
| 49 | |||
| 50 | For more documentation on the manifest format, including the local_manifests | ||
| 51 | support, see the [manifest-format.md] file. | ||
| 52 | |||
| 53 | * `manifests/`: A git checkout of the manifest project. Its `.git/` state | ||
| 54 | points to the `manifest.git` bare checkout (see below). It tracks the git | ||
| 55 | branch specified at `repo init` time via `--manifest-branch`. | ||
| 56 | |||
| 57 | The local branch name is always `default` regardless of the remote tracking | ||
| 58 | branch. Do not get confused if the remote branch is not `default`, or if | ||
| 59 | there is a remote `default` that is completely different! | ||
| 60 | |||
| 61 | No manual changes should be made in here as it will just confuse repo and | ||
| 62 | it won't automatically recover causing no new changes to be picked up. | ||
| 63 | |||
| 64 | * `manifests.git/`: A bare checkout of the manifest project. It tracks the | ||
| 65 | git repository specified at `repo init` time via `--manifest-url`. | ||
| 66 | |||
| 67 | No manual changes should be made in here as it will just confuse repo. | ||
| 68 | If you want to switch the tracking settings, re-run `repo init` with the | ||
| 69 | new settings. | ||
| 70 | |||
| 71 | * `manifest.xml`: The manifest that repo uses. It is generated at `repo init` | ||
| 72 | and uses the `--manifest-name` to determine what manifest file to load next | ||
| 73 | out of `manifests/`. | ||
| 74 | |||
| 75 | Do not try to modify this to load other manifests as it will confuse repo. | ||
| 76 | If you want to switch manifest files, re-run `repo init` with the new | ||
| 77 | setting. | ||
| 78 | |||
| 79 | Older versions of repo managed this with symlinks. | ||
| 80 | |||
| 81 | * `manifest.xml -> manifests/<manifest-name>.xml`: A symlink to the manifest | ||
| 82 | that the user wishes to sync. It is specified at `repo init` time via | ||
| 83 | `--manifest-name`. | ||
| 84 | |||
| 85 | |||
| 86 | * `manifests.git/.repo_config.json`: JSON cache of the `manifests.git/config` | ||
| 87 | file for repo to read/process quickly. | ||
| 88 | |||
| 89 | * `local_manifest.xml` (*Deprecated*): User-authored tweaks to the manifest | ||
| 90 | used to sync. See [local manifests] for more details. | ||
| 91 | * `local_manifests/`: Directory of user-authored manifest fragments to tweak | ||
| 92 | the manifest used to sync. See [local manifests] for more details. | ||
| 93 | |||
| 94 | ### Project objects | ||
| 95 | |||
| 96 | *** note | ||
| 97 | **Warning**: Please do not use repo's approach to projects/ & project-objects/ | ||
| 98 | layouts as a model for other tools to implement similar approaches. | ||
| 99 | It has a number of known downsides like: | ||
| 100 | * [Symlinks do not work well under Windows](./windows.md). | ||
| 101 | * Git sometimes replaces symlinks under .git/ with real files (under unknown | ||
| 102 | circumstances), and then the internal state gets out of sync, and data loss | ||
| 103 | may ensue. | ||
| 104 | * When sharing project-objects between multiple project checkouts, Git might | ||
| 105 | automatically run `gc` or `prune` which may lead to data loss or corruption | ||
| 106 | (since those operate on leaf projects and miss refs in other leaves). See | ||
| 107 | https://gerrit-review.googlesource.com/c/git-repo/+/254392 for more details. | ||
| 108 | |||
| 109 | Instead, you should use standard Git workflows like [git worktree] or | ||
| 110 | [gitsubmodules] with [superprojects]. | ||
| 111 | *** | ||
| 112 | |||
| 113 | * `copy-link-files.json`: Tracking file used by `repo sync` to determine when | ||
| 114 | copyfile or linkfile are added or removed and need corresponding updates. | ||
| 115 | * `project.list`: Tracking file used by `repo sync` to determine when projects | ||
| 116 | are added or removed and need corresponding updates in the checkout. | ||
| 117 | * `projects/`: Bare checkouts of every project synced by the manifest. The | ||
| 118 | filesystem layout matches the `<project path=...` setting in the manifest | ||
| 119 | (i.e. where it's checked out in the repo client source tree). Those | ||
| 120 | checkouts will symlink their `.git/` state to paths under here. | ||
| 121 | |||
| 122 | Some git state is further split out under `project-objects/`. | ||
| 123 | * `project-objects/`: Git objects that are safe to share across multiple | ||
| 124 | git checkouts. The filesystem layout matches the `<project name=...` | ||
| 125 | setting in the manifest (i.e. the path on the remote server) with a `.git` | ||
| 126 | suffix. This allows for multiple checkouts of the same remote git repo to | ||
| 127 | share their objects. For example, you could have different branches of | ||
| 128 | `foo/bar.git` checked out to `foo/bar-main`, `foo/bar-release`, etc... | ||
| 129 | There will be multiple trees under `projects/` for each one, but only one | ||
| 130 | under `project-objects/`. | ||
| 131 | |||
| 132 | This layout is designed to allow people to sync against different remotes | ||
| 133 | (e.g. a local mirror & a public review server) while avoiding duplicating | ||
| 134 | the content. However, this can run into problems if different remotes use | ||
| 135 | the same path on their respective servers. Best to avoid that. | ||
| 136 | * `subprojects/`: Like `projects/`, but for git submodules. | ||
| 137 | * `subproject-objects/`: Like `project-objects/`, but for git submodules. | ||
| 138 | * `worktrees/`: Bare checkouts of every project synced by the manifest. The | ||
| 139 | filesystem layout matches the `<project name=...` setting in the manifest | ||
| 140 | (i.e. the path on the remote server) with a `.git` suffix. This has the | ||
| 141 | same advantages as the `project-objects/` layout above. | ||
| 142 | |||
| 143 | This is used when [git worktree]'s are enabled. | ||
| 144 | |||
| 145 | ### Global settings | ||
| 146 | |||
| 147 | The `.repo/manifests.git/config` file is used to track settings for the entire | ||
| 148 | repo client checkout. | ||
| 149 | |||
| 150 | Most settings use the `[repo]` section to avoid conflicts with git. | ||
| 151 | |||
| 152 | Everything under `[repo.syncstate.*]` is used to keep track of sync details for logging | ||
| 153 | purposes. | ||
| 154 | |||
| 155 | User controlled settings are initialized when running `repo init`. | ||
| 156 | |||
| 157 | | Setting | `repo init` Option | Use/Meaning | | ||
| 158 | |------------------- |---------------------------|-------------| | ||
| 159 | | manifest.groups | `--groups` & `--platform` | The manifest groups to sync | | ||
| 160 | | manifest.standalone | `--standalone-manifest` | Download manifest as static file instead of creating checkout | | ||
| 161 | | repo.archive | `--archive` | Use `git archive` for checkouts | | ||
| 162 | | repo.clonebundle | `--clone-bundle` | Whether the initial sync used clone.bundle explicitly | | ||
| 163 | | repo.clonefilter | `--clone-filter` | Filter setting when using [partial git clones] | | ||
| 164 | | repo.depth | `--depth` | Create shallow checkouts when cloning | | ||
| 165 | | repo.dissociate | `--dissociate` | Dissociate from any reference/mirrors after initial clone | | ||
| 166 | | repo.mirror | `--mirror` | Checkout is a repo mirror | | ||
| 167 | | repo.partialclone | `--partial-clone` | Create [partial git clones] | | ||
| 168 | | repo.partialcloneexclude | `--partial-clone-exclude` | Comma-delimited list of project names (not paths) to exclude while using [partial git clones] | | ||
| 169 | | repo.reference | `--reference` | Reference repo client checkout | | ||
| 170 | | repo.submodules | `--submodules` | Sync git submodules | | ||
| 171 | | repo.superproject | `--use-superproject` | Sync [superproject] | | ||
| 172 | | repo.worktree | `--worktree` | Use [git worktree] for checkouts | | ||
| 173 | | user.email | `--config-name` | User's e-mail address; Copied into `.git/config` when checking out a new project | | ||
| 174 | | user.name | `--config-name` | User's name; Copied into `.git/config` when checking out a new project | | ||
| 175 | |||
| 176 | [partial git clones]: https://git-scm.com/docs/gitrepository-layout#_code_partialclone_code | ||
| 177 | [superproject]: https://en.wikibooks.org/wiki/Git/Submodules_and_Superprojects | ||
| 178 | |||
| 179 | ### Repo hooks settings | ||
| 180 | |||
| 181 | For more details on this feature, see the [repo-hooks docs](./repo-hooks.md). | ||
| 182 | We'll just discuss the internal configuration settings. | ||
| 183 | These are stored in the registered `<repo-hooks>` project itself, so if the | ||
| 184 | manifest switches to a different project, the settings will not be copied. | ||
| 185 | |||
| 186 | | Setting | Use/Meaning | | ||
| 187 | |--------------------------------------|-------------| | ||
| 188 | | repo.hooks.\<hook\>.approvedmanifest | User approval for secure manifest sources (e.g. https://) | | ||
| 189 | | repo.hooks.\<hook\>.approvedhash | User approval for insecure manifest sources (e.g. http://) | | ||
| 190 | |||
| 191 | |||
| 192 | For example, if our manifest had the following entries, we would store settings | ||
| 193 | under `.repo/projects/src/repohooks.git/config` (which would be reachable via | ||
| 194 | `git --git-dir=src/repohooks/.git config`). | ||
| 195 | ```xml | ||
| 196 | <project path="src/repohooks" name="chromiumos/repohooks" ... /> | ||
| 197 | <repo-hooks in-project="chromiumos/repohooks" ... /> | ||
| 198 | ``` | ||
| 199 | |||
| 200 | If `<hook>` is `pre-upload`, the `.git/config` setting might be: | ||
| 201 | ```ini | ||
| 202 | [repo "hooks.pre-upload"] | ||
| 203 | approvedmanifest = https://chromium.googlesource.com/chromiumos/manifest | ||
| 204 | ``` | ||
| 205 | |||
| 206 | ## Per-project settings | ||
| 207 | |||
| 208 | These settings are somewhat meant to be tweaked by the user on a per-project | ||
| 209 | basis (e.g. `git config` in a checked out source repo). | ||
| 210 | |||
| 211 | Where possible, we re-use standard git settings to avoid confusion, and we | ||
| 212 | refrain from documenting those, so see [git-config] documentation instead. | ||
| 213 | |||
| 214 | See `repo help upload` for documentation on `[review]` settings. | ||
| 215 | |||
| 216 | The `[remote]` settings are automatically populated/updated from the manifest. | ||
| 217 | |||
| 218 | The `[branch]` settings are updated by `repo start` and `git branch`. | ||
| 219 | |||
| 220 | | Setting | Subcommands | Use/Meaning | | ||
| 221 | |-------------------------------|---------------|-------------| | ||
| 222 | | review.\<url\>.autocopy | upload | Automatically add to `--cc=<value>` | | ||
| 223 | | review.\<url\>.autoreviewer | upload | Automatically add to `--reviewers=<value>` | | ||
| 224 | | review.\<url\>.autoupload | upload | Automatically answer "yes" or "no" to all prompts | | ||
| 225 | | review.\<url\>.uploadhashtags | upload | Automatically add to `--hashtag=<value>` | | ||
| 226 | | review.\<url\>.uploadlabels | upload | Automatically add to `--label=<value>` | | ||
| 227 | | review.\<url\>.uploadnotify | upload | [Notify setting][upload-notify] to use | | ||
| 228 | | review.\<url\>.uploadtopic | upload | Default [topic] to use | | ||
| 229 | | review.\<url\>.username | upload | Override username with `ssh://` review URIs | | ||
| 230 | | remote.\<remote\>.fetch | sync | Set of refs to fetch | | ||
| 231 | | remote.\<remote\>.projectname | \<network\> | The name of the project as it exists in Gerrit review | | ||
| 232 | | remote.\<remote\>.pushurl | upload | The base URI for pushing CLs | | ||
| 233 | | remote.\<remote\>.review | upload | The URI of the Gerrit review server | | ||
| 234 | | remote.\<remote\>.url | sync & upload | The URI of the git project to fetch | | ||
| 235 | | branch.\<branch\>.merge | sync & upload | The branch to merge & upload & track | | ||
| 236 | | branch.\<branch\>.remote | sync & upload | The remote to track | | ||
| 237 | |||
| 238 | ## ~/ dotconfig layout | ||
| 239 | |||
| 240 | Repo will create & maintain a few files in the user's home directory. | ||
| 241 | |||
| 242 | * `.repoconfig/`: Repo's per-user directory for all random config files/state. | ||
| 243 | * `.repoconfig/config`: Per-user settings using [git-config] file format. | ||
| 244 | * `.repoconfig/keyring-version`: Cache file for checking if the gnupg subdir | ||
| 245 | has all the same keys as the repo launcher. Used to avoid running gpg | ||
| 246 | constantly as that can be quite slow. | ||
| 247 | * `.repoconfig/gnupg/`: GnuPG's internal state directory used when repo needs | ||
| 248 | to run `gpg`. This provides isolation from the user's normal `~/.gnupg/`. | ||
| 249 | |||
| 250 | * `.repoconfig/.repo_config.json`: JSON cache of the `.repoconfig/config` | ||
| 251 | file for repo to read/process quickly. | ||
| 252 | * `.repo_.gitconfig.json`: JSON cache of the `.gitconfig` file for repo to | ||
| 253 | read/process quickly. | ||
| 254 | |||
| 255 | |||
| 256 | [git-config]: https://git-scm.com/docs/git-config | ||
| 257 | [git worktree]: https://git-scm.com/docs/git-worktree | ||
| 258 | [gitsubmodules]: https://git-scm.com/docs/gitsubmodules | ||
| 259 | [manifest-format.md]: ./manifest-format.md | ||
| 260 | [local manifests]: ./manifest-format.md#Local-Manifests | ||
| 261 | [superprojects]: https://en.wikibooks.org/wiki/Git/Submodules_and_Superprojects | ||
| 262 | [topic]: https://gerrit-review.googlesource.com/Documentation/intro-user.html#topics | ||
| 263 | [upload-notify]: https://gerrit-review.googlesource.com/Documentation/user-upload.html#notify | ||
