Files
git-repo/docs/repoconfig.md
T
Insaf Latypov 9991aa6177 config: add subcommand to manage ~/.repoconfig/config
Per-user settings such as sync.smartsync live in ~/.repoconfig/config,
but reading or changing them required knowing the file location and
running `git config --file ~/.repoconfig/config ...`.

Add `repo config` as a thin wrapper around RepoConfig.ForUser(),
following the subcommand style of modern `git config`:
* `repo config get <name>` prints the value(s), exiting 1 if unset.
* `repo config set <name> <value>` sets it.
* `repo config unset <name>` removes it; a missing key is a no-op.
* `repo config list` shows all settings.

Values are stored as strings; `--type=bool|int` validates and
canonicalizes them on set and get, like `git config --type`.  `-z` makes
get and list NUL-terminated for scripting.  Setting names are validated
by `git config` itself when writing.

Factor the value parsing out of GitConfig.GetBoolean()/GetInt() into
ParseBoolean()/ParseInt() so the command and the readers agree, and
accept on/off/1/0 as booleans like git does.

Only the per-user file is handled; per-checkout settings in
.repo/manifests.git/config are out of scope.  Like other subcommands, it
runs from inside a repo checkout.

Update docs/repoconfig.md to use the new command in its examples and
add zsh completion and the man page.

Bug: 569927750
Test: ./run_tests
Change-Id: I940d0318549fe9d79f6f9173139f0b96a706f1bf
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/645727
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Insaf Latypov <saferif@google.com>
Commit-Queue: Insaf Latypov <saferif@google.com>
2026-10-22 08:34:46 -07:00

3.0 KiB

repoconfig: User Configuration

Repo keeps a small number of settings that apply to the current user rather than to one checkout. They live in the per-user configuration file ~/.repoconfig/config, which is separate from both git's own ~/.gitconfig and the per-checkout settings stored in .repo/manifests.git/config (see internal-fs-layout.md for those).

[TOC]

Location

The file is .repoconfig/config inside the user's home directory. The parent directory can be changed by setting the REPO_CONFIG_DIR environment variable, in which case repo reads $REPO_CONFIG_DIR/.repoconfig/config instead.

The file is created on demand; it's fine for it to be missing.

Format

The file uses the git-config syntax. The easiest way to manage it is the repo config command:

# Set a value.
repo config set sync.smartsync true

# Read a value.
repo config get sync.smartsync

# Remove a value.
repo config unset sync.smartsync

# Show all settings.
repo config list

Like other repo subcommands, repo config must be run from inside a repo checkout. The file can also be edited by hand:

[sync]
	smartsync = true

Boolean settings accept true/yes and false/no.

Settings

alias.*

alias.<name> defines repo <name> as a shortcut for another subcommand, optionally with arguments, in the same way as git aliases:

[alias]
	ss = sync -s
	st = status -o

Aliases defined in a checkout's .repo/config take precedence over per-user ones. Existing subcommands cannot be overridden by an alias.

sync

smartsync

sync.smartsync is a boolean that lets a user decide once, for all their checkouts, whether repo sync should Smart Sync by default: true always Smart Syncs, as if -s/--smart-sync were passed; false never does by default, even if the manifest sets sync-smartsync="true"; unset follows the manifest.

The effective behavior is resolved in this order; the first match wins:

  1. Command line: -s/--smart-sync, --no-smart-sync, or -t/--smart-tag.
  2. User config: sync.smartsync in ~/.repoconfig/config.
  3. Manifest: sync-smartsync="true" on the <default> element.
  4. Otherwise, a regular ToT sync.

So sync.smartsync=false turns off the manifest-driven default, but an explicit repo sync -s, repo sync -t TAG or repo smartsync still works. Likewise sync.smartsync=true is overridden by --no-smart-sync.

A Smart Sync enabled by sync.smartsync=true is treated as an explicit request: it is subject to the same restrictions as -s (it is skipped when -l/--local-only, -m/--manifest-name, -t/--smart-tag or --superproject-revision is used), and a failure to obtain a manifest from the server fails the sync instead of silently falling back to ToT.

sync.smartsync does not affect -l/--local-only: a local-only sync keeps whatever smart_sync_override.xml the previous network sync left behind. See smart-sync.md for details.