* A submodule's working-tree `.git` names the git directory git uses for
it. Before any submodule command (update, or deinit when submodules
are turned off), and before an import, every `.git` below the top of
the working tree must be a file pointing inside the repo's own
.git/modules; a link, a directory, or a file pointing elsewhere could
make git use a config that was never checked.
* Import validates and sanitizes the clone where it is, then moves it,
and moves it back if marking it fails, so a refused or failed import
never leaves a clone moved without a Repo.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ownership marker held the Repo's URL key, which anyone can write, so
a copied clone, an extracted archive or a hand-made `.git` passed the
check and was reset and cleaned. Each Repo now has a random clone_token
(repository column and repos.yaml, so a Repo restored from the config
still owns its clone); the marker holds it, and only a clone holding the
Repo's token is updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A submodule git directory which borrows another (commondir) has no
objects of its own, and was skipped instead of refused, because
"has objects/" decided what a git directory was. The walk now follows
git's layout: under .git/modules every directory holding HEAD is a git
directory (whatever the submodule's name, even `refs`), which must not
borrow, must have its own objects and a regular config, and is
sanitized; nested submodules are found in its own `modules`, and its
refs and logs are never mistaken for git directories.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The checks covered .git but not the submodules' git directories in
.git/modules: a linked submodule config was skipped (and still read by
git), and a submodule's commondir or alternates were not refused. Every
git directory now needs a regular config and must not borrow another
directory, and nothing under .git/modules may be a link; otherwise the
update fails. A git directory is one with HEAD and objects (a ref named
HEAD is not one).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A clone with .git/commondir (git then reads another directory's config,
refs and objects, so the sanitized config is not the one read) or
alternates is neither imported nor updated.
* branch.*.remote/merge are no longer kept: WROLPi checks out with -B and
needs neither, and branch.<name>.remote can be a URL git uses to resolve
relative submodule URLs.
* An import directory is resolved and confined to the media directory
before anything about it is reported, so a link cannot reveal whether a
path outside exists.
* git_command also turns off automatic maintenance (gc.auto,
maintenance.auto) and core.alternateRefsCommand.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A clone being imported is controlled by whoever put it in the media
directory. A link at .git/wrolpi-repo or .git/config.wrolpi made the
marker and the sanitized config write wherever it pointed. The marker
is written with O_NOFOLLOW (after removing a link), the sanitized config
through mkstemp, and a .git/config which is not a regular file is
refused (by Import, and before an update).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The sanitized config is written as INI by WROLPi (values quoted), so
no kept value is ever passed to `git config` as an argument.
* origin's url and fetch refspec are set with --replace-all (a planted
duplicate made `git config key value` fail), in both modes.
* format_repo_destination formats a Repo's directory from its name, Tag,
owner and host, so a directory can be known before the Repo exists
(Import shows it); Collection.format_destination uses it for repos.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An update resets and cleans the clone, and fetched from whatever the
clone's `origin` said, trusting its .git/config. A clone WROLPi did not
make (in the Repo's directory, or swapped in) could lose local work, be
mirrored from another repo, or redirect git with planted settings
(include.path, url.*.insteadOf, http.proxy, core.sshCommand, ...).
* WROLPi marks its clones (.git/wrolpi-repo holds the Repo's URL key);
an unmarked clone, or `.git` that is not a directory, is not updated.
* Every update fetches the Repo's URL (origin is reset to it).
* Before an update, the clone's config (and its submodules') keeps only
the settings WROLPi needs; a submodule's work tree must be inside the
repo.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>