summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* sync: Add --superproject-rev flag to sync to specific revisionv2.64stableGavin Mak2026-05-205-10/+271
| | | | | | | | | | | | | | | | | Allow syncing the outer manifest to a state defined by a specific superproject revision. It updates the superproject, reads the manifest commit from .supermanifest, and checks out the outer manifest project to that commit. Submanifests are then processed normally, allowing them to be updated to the revisions specified in the new outer manifest state. Bug: 416589884 Change-Id: I304c37a2b8794f9b74cb7e5e209a8a93762bdb52 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/576321 Commit-Queue: Gavin Mak <gavinmak@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* Fix submodules not synced for repeated repoJosef Malmström2026-05-202-1/+90
| | | | | | | | | | | | | | | | | | | If I check out e.g. multiple branches of the same repo in one manifest, only the submodules of one checkout are synced. Fix this by adding the relative path of the checkout as a key to the mapping of derived projects, preventing overwrite. The fix was originally proposed here: https://issues.gerritcodereview.com/issues/40013218 Bug: 40013218 Change-Id: Ia86518ccf2c0af7bd7e4daf8d703a55b7e10ba52 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/581062 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Josef Malmstrom <Josef.Malmstrom@arm.com> Tested-by: Josef Malmstrom <Josef.Malmstrom@arm.com>
* Automated: Migrate gerrit/git-repo from gsutil to gcloud storagegurusai-voleti2026-05-142-10/+11
| | | | | | | | | Bug: 486536908 Change-Id: I248b093e189a3784b8959e837a5d66857f1ce0fc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/577201 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Guru sai rama subbarao Voleti (xWF) <gvoleti@google.com> Commit-Queue: Guru sai rama subbarao Voleti (xWF) <gvoleti@google.com>
* abandon/start/info: Make them respect smart sync overrideGavin Mak2026-05-143-0/+4
| | | | | | | | | | | | | | | | Call TryOverrideManifestWithSmartSync in start, abandon, and info commands. This ensures they pick up the pinned revisions from the smart sync override manifest if it exists, rather than falling back to ToT from the default manifest. Bug: 279204331 Change-Id: I637f054a77773805daf0bf9cf5a712d82a5959b4 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/582503 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* command: Move smart sync override logic to Command base classGavin Mak2026-05-143-10/+18
| | | | | | | | | | | | | Deduplicate the logic for loading `smart_sync_override.xml` by moving it from `forall.py` to the `Command` base class. This allows other commands to reuse it to respect smart tags. Bug: 279204331 Change-Id: I6f2f03995266c2a68c3225cacb92b2f580a89178 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/582502 Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* docs: drop period in headersMike Frysinger2026-05-142-3/+3
| | | | | | | | | | We don't do this in most places, so standardize the outliers. Change-Id: I80c1ef16c5fa7355dcb7797bc8e56852b22c24d5 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/583641 Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* run_tests: help2man: update to latest releaseMike Frysinger2026-05-143-10/+10
| | | | | | | | Change-Id: I30e4a6452ac5504b782fe545a59ca1f58ac70385 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/583621 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* Fix missing `None` check in Remote.SaveJosef Malmström2026-05-132-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | This code was causing an exception in cases where `pushUrl` was set but `projectname` was not. This can happen when `pushUrl` is set for the manifest repo which does not have a `projectname`. For example: repo init --manifest-url ssh://url.to/my/manifest cd .repo/manifests git config remote.origin.pushurl ssh://url.to/my/manifest repo init --manifest-url ssh://url.to/my/manifest --repo-rev main The last `repo init` invocation causes an error. Change-Id: Ibb68c8446880cfbac22feee595d1fd1b678c7ade Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/579162 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Josef Malmstrom <Josef.Malmstrom@arm.com> Tested-by: Josef Malmstrom <Josef.Malmstrom@arm.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* Add support for self referencing submodulesJosef Malmström2026-05-132-1/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When working with relative submodule paths, The "./" needs special handling similar to "../". See information on: https://git-scm.com/docs/git-submodule Which currently states: "<repository> is the URL of the new submodule’s origin repository. This may be either an absolute URL, or (if it begins with ./ or ../), the location relative to the superproject’s default remote repository (Please note that to specify a repository foo.git which is located right next to a superproject bar.git, you’ll have to use ../foo.git instead of ./foo.git - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories)." The implementation also was not handling file/directory names starting with "." or "..". Explicitly look for "./" and "../" instead. Change-Id: I8ae68d61fb0cbb1624183b175236e98a36e4afdb Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/579182 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Josef Malmstrom <Josef.Malmstrom@arm.com> Tested-by: Josef Malmstrom <Josef.Malmstrom@arm.com>
* release: update-manpages: revert color filteringMike Frysinger2026-05-122-26/+1
| | | | | | | | | | | We pull a pinned help2man from cipd now, so we should get stable behavior between developers. That means the color filtering should not be necessary anymore, and we can drop the logic & unittest. Change-Id: Ib53e1ce7f8d610d7f624c9a019c79dc5f438ac0d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/582402 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* linkfile: Handle directory-to-symlink transitions safelyCarlos Fernandez2026-05-126-9/+320
| | | | | | | | | | | | | | | | | | | | | | | | | | When a manifest changes from individual linkfiles inside a directory (e.g. dest=".llms/rules", dest=".llms/skills") to a single linkfile for the whole directory (e.g. dest=".llms", src="dot-llms"), two things need to happen: 1. __linkIt must replace a real directory with a symlink. Use os.rmdir() instead of platform_utils.remove() for real directories. rmdir only removes empty directories, so user-created content is never deleted. 2. UpdateCopyLinkfileList must handle the cleanup correctly: - Use os.rmdir() for directories (safe for non-empty) - Remove empty parent directories after cleaning old dests - Retry _CopyAndLinkFiles for all projects, since in interleaved sync mode _CopyAndLinkFiles runs before cleanup and may have failed because the directory was not yet empty Change-Id: I0437b80beab98bce064cea81c11c47d699be91aa Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/569243 Tested-by: Carlos Fernandez <carlosfsanz@meta.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Carlos Fernandez <carlosfsanz@meta.com>
* run_tests: leverage cipd when available for help2manMike Frysinger2026-05-126-10/+76
| | | | | | | | | | | | | This tool isn't installed on CI bot images so we've been skipping it, but this is causing people to not run tests locally, and ignore errors. Use cipd to pull the tool in when available. Then revert a recent man change that the tool rejects. Change-Id: I1030d0070fd5a624656eba7434ae6ec99b2e3f2d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/582401 Reviewed-by: Greg Edelston <gredelston@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* sync: Re-raise KeyboardInterrupt in main processGavin Mak2026-05-123-0/+63
| | | | | | | | | | | | | | | | When running sync -j1, worker functions run directly in the main process. Swallowing KeyboardInterrupt causes the loop to continue to the next project instead of aborting. Re-raise KeyboardInterrupt if running in the MainProcess, while maintaining the suppression of stack traces in worker processes. Bug: 468170157 Change-Id: I156d66bc209a265f7fa25eea0eb88737d1b51a34 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/581342 Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com>
* git_config: fix error message command outputMike Frysinger2026-05-121-1/+1
| | | | | | | | | | | | | | | | | | str() inside an f-string is redundant. Actually join the array together as a string to show a proper error message, and include the full command line, not the extra options passed in. Before: error.GitError: git config ('--null', '--list'): fatal: unable to read config file 'xxx': No such file or directory After: error.GitError: git config --system --includes --null --list: fatal: unable to read config file 'xxx': No such file or directory Change-Id: I8983389aa2e0de7808991e73e636b77810f04c4b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/582341 Commit-Queue: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* info: Parallelize repo info to improve performanceGreg Edelston2026-05-123-95/+183
| | | | | | | | | | | | | | | | | | | | | For a large checkout like chromiumos or android, `repo info` takes a really long time! On my machine it took ~6 minutes. On a randomly selected ChromiumOS cq-orchestrator build it took 4.1 minutes: https://ci.chromium.org/b/8682060180498819729. This adds up to a lot of wasted runtime for both humans and bots. The problem is that `repo info` was single-threaded, which causes poor performance when the checkout has 1000+ projects. We already have a pattern for parallelization; let's use it. BUG=None TEST=Manually run, ensure no diff Change-Id: I6b82b9495eb2a0e602a142dd3a16f09217871e1b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/581921 Tested-by: Greg Edelston <gredelston@google.com> Commit-Queue: Greg Edelston <gredelston@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* sync: Exclude stateless sync pruned projects from bloat checkGavin Mak2026-05-112-1/+21
| | | | | | | | | | | | If a project has been pruned for stateless sync, it has already undergone aggressive garbage collection. There should be no bloat to check for. Change-Id: I9233a4611e05b7a0b7c097827d6f408144f7380d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/581841 Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Becky Siegel <beckysiegel@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* completion: document installation and usage in READMEGavin Mak2026-05-081-0/+37
| | | | | | | | | | | Add a "Shell Completion" section to README.md to document how to install and use `completion.bash` and `completion.zsh`. Change-Id: Ibf6c81043af6c24d45ea2dc6a6caa26d98ab7374 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/581261 Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* sync: Suggest "git repack -a -d" in bloat warningGavin Mak2026-05-081-2/+2
| | | | | | | | | | | | | | | | | | The warning suggests running "repo sync --auto-gc" which runs "git gc --auto". Git may decide not to repack if its internal thresholds are not met, leaving the warning active even after running the suggested command. "git repack -a -d" forces all reachable objects into a single pack and deletes redundant packs, reducing the pack count to 1. This guarantees that the warning (which triggers when pack count exceeds 10) goes away. Bug: 505755299 Change-Id: I10163ef8efb7f3b7c5055378ad95051974d11b88 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/580821 Reviewed-by: Becky Siegel <beckysiegel@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Tested-by: Gavin Mak <gavinmak@google.com>
* Add zsh completionKamal Sacranie2026-05-081-0/+449
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR adds `completion.zsh` to allow for relatively intelligent completion of `repo` command-line arguments for all commands of the `repo` CLI. The `completion.zsh` can be added to your zsh completions by copying (and renaming) the completion script to a directory that you have added to your zsh completion path. ``` cp completion.zsh $ZSH_COMPLETION_DIRECTORY/_repo ``` You must name the file `_repo` for it to register as completion for `repo`. You can add a directory to your zsh completion by updating your `fpath` variable before calling `compinit` as follows: ``` fpath=( /path/to/zsh-completions/dir $fpath ) ``` Future work: Generate this file using the subcommand classes and python reflection. Change-Id: I6a4e785c1efcf9076bd693976ac03578836b691b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/579561 Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Kamal Sacranie <sacranie@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* forall: Document REPO_UPSTREAM and REPO_DEST_BRANCH envvarsGavin Mak2026-05-072-1/+12
| | | | | | | Change-Id: I74365295152f8828587c6b4ed93029efc6000881 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/580761 Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* info: add --format and --include-summary/--include-projects optionsCarlos Fernandez2026-05-073-21/+349
| | | | | | | | | | | | | | | | | | | Add --format={text,json} to produce machine-readable output, and boolean options to control which sections are displayed: --include-summary / --no-include-summary (default: on) --include-projects / --no-include-projects (default: on) The JSON output respects the include flags, so callers can request only the fields they need (e.g. `repo info --format=json --no-include-projects` for manifest metadata only). Change-Id: I9641bc4023b630d9c61c5170eb86e5f3b787236f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/569203 Commit-Queue: Carlos Fernandez <carlosfsanz@meta.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Carlos Fernandez <carlosfsanz@meta.com> Tested-by: Carlos Fernandez <carlosfsanz@meta.com>
* sync: Fix force_checkout propagationJosef Malmström2026-05-062-1/+31
| | | | | | | | | | | | | | | | | The force_checkout parameter was not propagated in all calls to Checkout in Sync_LocalHalf. Without this, repo sync --force-checkout can still fail for projects currently on a local branch with no upstream/tracking configuration, because the detach-to-manifest checkout was executed without -f, leaving local modifications or untracked files able to block sync. Change-Id: I58551388e2f906c4db96e220707a369057a71c24 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/579181 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Josef Malmstrom <Josef.Malmstrom@arm.com> Tested-by: Josef Malmstrom <Josef.Malmstrom@arm.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* git_superproject: Remove redundant _branch variableGavin Mak2026-04-282-6/+7
| | | | | | | | | | | Both variables were initialized to the same value and never modified. Bug: 416589884 Change-Id: Iaa1ffffb4543d4cd9391ac679d9234fe01678861 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/576921 Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* tests: Add tests for repo status outputNasser Grainawi2026-04-231-0/+220
| | | | | | | | | | | | | | | | | | Build out status subcommand unit coverage using a minimal fake repo checkout wired through XmlManifest. The new tests verify: - clean status output prints the expected project header - modified tracked files appear with the expected status marker - `-o` output includes the orphan section and orphan entries - branch names shown in status reflect a started non-default branch Change-Id: Ia7c22593d0bbdc4aed81faeb168b846f3e4016ab Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/558501 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com> Commit-Queue: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* color: type SetDefaultColoring and drop bool statesNasser Grainawi2026-04-222-3/+15
| | | | | | | | | | | | | | Also add a test fixture to always disable coloring so that we get reproducible test behavior. The few tests that want to check color behavior (e.g. test_color.py) can still reset/change color values as needed. Change-Id: I1808139a63e0862c29bf81d7097e885ca8561040 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/573621 Reviewed-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com> Tested-by: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com>
* Add timing keyword argument for hooksRam Peri2026-04-214-5/+58
| | | | | | | | | | | | | | | | | | | | | Measure the duration of the sync operation in the Execute method of the Sync command and pass it to post-sync hooks as a standard keyword argument (`sync_duration_seconds`). Updates based on code review: - Update _API_ARGS in hooks.py to allow sync_duration_seconds for post-sync hooks. - Do not cast sync_duration_seconds to int for better granularity. - Update docs/repo-hooks.md to document sync_duration_seconds. - Add unit test for argument validation in test_hooks.py. Test: Ran run_tests using venv python, all 554 tests passed. Bug: TBD Change-Id: Ie29e002a5d283460d993ad96c224dbf4b6d7985c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/575021 Tested-by: Arif Kasim <arifkasim@google.com> Commit-Queue: Ram Peri <ramperi@google.com> Reviewed-by: Arif Kasim <arifkasim@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* sync: Refactor to use _RunOneGC and fix config leakagev2.63Gavin Mak2026-04-202-26/+42
| | | | | | | | | | | | | | | | Extract _RunOneGC to handle GC on a single project. This refactoring makes it easier to invoke GC from parallel worker tasks. Also, avoid modifying the passed-in config dictionary in _RunOneGC by creating a local copy, preventing unintended side effects on other commands sharing the same config. Bug: 498290329 Change-Id: I7b77ed6629b14b5ee3322870b9c6c8ce2bfd6ea2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/574923 Reviewed-by: Becky Siegel <beckysiegel@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* sync: Switch to using self._bloated_projectsGavin Mak2026-04-202-13/+14
| | | | | | | | | | | | Store bloated projects in self._bloated_projects and print warnings at the end of execution. This sets up for moving the check to workers. Bug: 498290329 Change-Id: I993f1fd741db2994d480994861588eb18f6c5503 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/574922 Reviewed-by: Becky Siegel <beckysiegel@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* tests: Add tests for _CheckForBloatedProjects and _GCProjectsGavin Mak2026-04-201-0/+107
| | | | | | | | Change-Id: I6790a13929b8fc06a3197ca405dedf08d39d54c9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/574926 Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Becky Siegel <beckysiegel@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* upload: Clarify partial sync message on hook failureMarty Heavey2026-04-201-3/+4
| | | | | | | | | | | | | | | Demote the partial sync warning from error to info and rephrase it to be a tip rather than an error. This prevents users from thinking that a partial sync is the cause of their hook failures when it is often a linting failure. The message now suggests that a full sync might help if there are cross-project dependencies, instead of implying it will fix any issue. Change-Id: I5d8c52b53ac315aa9f145ed069798bf201fa0815 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/574262 Tested-by: Marty Heavey <mheavey@google.com> Commit-Queue: Marty Heavey <mheavey@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* sync: Provide feedback during post-sync operationsGavin Mak2026-04-171-0/+3
| | | | | | | | | | | | | After the main sync progress bar finishes, there's a pause while some post-sync operations run. Print something to provide feedback so the user doesn't think repo has hung. Bug: 503869525 Change-Id: I695fd560e60dcb394e6844a56c8a336ca1f71c74 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/574425 Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Becky Siegel <beckysiegel@google.com> Tested-by: Gavin Mak <gavinmak@google.com>
* progress: Ignore updates after progress endsGavin Mak2026-04-171-0/+2
| | | | | | | | | | | This addresses the occasional "..working.." message at the end of sync. Bug: 503869525 Change-Id: I489d29fa8ae588d77abb7fee5f157800d4abb368 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/574482 Commit-Queue: Gavin Mak <gavinmak@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Becky Siegel <beckysiegel@google.com>
* project: Avoid skipping fetches for shallow clones without .git/shallowBecky Siegel2026-04-172-0/+118
| | | | | | | | | | | | | | | | When optimizing fetches for projects with immutable revisions, the fetch should not be skipped if the project is configured for a shallow clone (depth > 0) but the .git/shallow file is missing. The absence of the .git/shallow file means the repository is not a shallow clone, or the shallow clone is incomplete, so a fetch is necessary to ensure the revision is present. Bug: 503081454 Change-Id: Ic3549612bcd69050a926652ee4e522c79ad8124c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/573821 Tested-by: Becky Siegel <beckysiegel@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Becky Siegel <beckysiegel@google.com>
* project: Drop --no-deref from update-ref --stdinMiyako.Enei2026-04-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | repo calls `git update-ref --stdin` when updating multiple refs during repo init and repo sync. Historically, `--no-deref` was also passed. Older Git 2.17 which we still support rejects the combination of `--stdin` and `--no-deref`, emitting a usage error even when the stdin input is valid. The `--no-deref` option is only meaningful when updating symbolic refs such as HEAD. The stdin-based update-ref path only operates on explicit refs (tags, remote refs, alternates) and never symbolic refs. Remove the unnecessary option to restore compatibility with Git 2.17 while preserving identical behavior on newer Git versions. Tested with: - Git 2.17.1 - Git 2.34.1 Change-Id: I22001de03800f5699b26a40bc1fb1fec002ed048 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/571721 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Enei <miyako.enei@alpsalpine.com> Tested-by: Enei <miyako.enei@alpsalpine.com>
* project: implement stateless sync pruning logicGavin Mak2026-04-092-0/+219
| | | | | | | | | | | | | | Implement in-situ shallow re-fetching and garbage collection logic. Enables repositories with sync-strategy="stateless" to reclaim disk space by running reflog expire and git gc --prune=now if the working tree is clean and has no local commits. Bug: 498730431 Change-Id: I940bdc9b74da29d3f7b13566667dcddea769ebd3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/568463 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* manifest: Add `sync-strategy` attribute to project elementsGavin Mak2026-04-095-21/+101
| | | | | | | | | | | | | | | | The only supported sync-strategy is "stateless". The intent is to keep the local workspace as small as possible by not keeping history during syncs. This prevents disk space waste for projects with large binaries where we only care about the current version. A follow up change will implement the logic. Bug: 498730431 Change-Id: I84a436a9ca2492893163c6cfda6c28dc62a568f0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/568462 Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* tests: Convert forall subcmd test to pytestNasser Grainawi2026-04-091-108/+76
| | | | | | | | | | | | | | | | | Rewrite tests/test_subcmds_forall.py from unittest.TestCase to pytest function-style tests to match the surrounding test suite conventions. Replace setUp/tearDown and class-based helpers with tmp_path-based setup, switch stdout capture to contextlib.redirect_stdout, and keep the existing behavior checks intact (all eight projects are invoked exactly once). Change-Id: I9243f3461aa6850f867bdb864f4a34c442f817f6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/569821 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com> Tested-by: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* gc: Fix hang during repack in partial clonesGavin Mak2026-04-081-4/+13
| | | | | | | | | | | | | | | | | | | Add `--missing=allow-promisor` to `git rev-list` calls in `repack_projects`. This prevents Git from auto-fetching missing objects from the promisor remote, which can cause stalls due to sequential network requests. Also add a Git version check to ensure Git is at least 2.17.0 before running `--repack`, as `--missing=allow-promisor` was introduced in that version. Bug: 500133631 Change-Id: I2dcf9b46fac4c6a53a3c2a46f06f61d6aec40f2f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/570361 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Sam Saccone <samccone@google.com>
* test_wrapper: add test for repo script executable permissionCarlos Fernandez2026-04-061-0/+5
| | | | | | | | | | | | Add a test to verify that the repo launcher script has the executable bit set, guarding against accidental permission changes. Change-Id: I314658b57ed174673188fbbc5962d9fdeefac97d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/569242 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Carlos Fernandez <carlosfsanz@meta.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Carlos Fernandez <carlosfsanz@meta.com>
* tests: convert more tests to pytestMike Frysinger2026-04-064-1206/+1308
| | | | | | | | Change-Id: Id4d48b61dc435564c336385bbc4944eb475d1942 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/569443 Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* tests: convert __file__ usage to pathlibMike Frysinger2026-04-061-7/+6
| | | | | | | | Change-Id: I2408b0ac97629f0d5fc92779b78bf1ff159a6f83 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/569442 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* tests: unify fixture() helper with Path constantMike Frysinger2026-04-065-22/+11
| | | | | | | | Change-Id: I63751042391f5cc3e06af7067bc83d67bd0716dc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/569441 Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* Fix all flake8 warnings from newer flake8-bugbear and flake8-comprehensionsCarlos Fernandez2026-04-0311-30/+39
| | | | | | | | | | | | | | | | | | | | | | | Address warnings introduced by flake8-bugbear 24.12.12 and flake8-comprehensions 3.16.0: - C408: Replace dict()/list() calls with literal {} and [] - C413: Remove unnecessary list() around sorted() - C414: Remove unnecessary list() inside sorted() - C419: Suppress intentional list comprehension in all() (noqa) - B001: Replace bare except with except Exception - B006: Replace mutable default arguments with None - B010: Replace setattr() with direct attribute assignment - B017: Use RuntimeError instead of Exception in tests - B019: Suppress lru_cache on methods for long-lived objects (noqa) - B033: Remove duplicate item in set literal Change-Id: If4693d3e946200bbc22f689f7b94da604addcb80 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/566321 Tested-by: Carlos Fernandez <carlosfsanz@meta.com> Commit-Queue: Carlos Fernandez <carlosfsanz@meta.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* project: Refactor GetHead to use symbolic-ref firstGavin Mak2026-04-021-23/+7
| | | | | | | | | | | | Simplify branch resolution and optimize unborn branch detection by prioritizing symbolic-ref over rev-parse. Change-Id: Ic62dcb87cd051dafb00d520b1157be2e32abc2ab Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/563222 Reviewed-by: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* Implement command forgiveness with autocorrectSam Saccone2026-03-242-13/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to `git`, when a user types an unknown command like `repo tart`, we now use `difflib.get_close_matches` to suggest similar commands. If `help.autocorrect` is set in the git config, it will optionally prompt the user to automatically run the assumed command, or wait for a configured delay before executing it. Verification Steps: 1. Created a dummy repo project locally. 2. Verified `help.autocorrect=0|false|off|no|show` suggests command and exits. 3. Verified `help.autocorrect=1|true|on|yes|immediate` automatically runs suggestion. 4. Verified `help.autocorrect=<number>` runs after `<number>*0.1` seconds. 5. Verified `help.autocorrect=never` exits immediately without suggestions. 6. Verified `help.autocorrect=prompt` asks user to accept [y/n] and handles correctly. BUG: b/489753302 Change-Id: I6dcd63229cbd7badf5404459b48690c68f5b4857 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/558021 Tested-by: Sam Saccone <samccone@google.com> Commit-Queue: Sam Saccone <samccone@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* docs: windows: mention Developer Mode for symlinksv2.62Mike Frysinger2026-03-201-2/+5
| | | | | | | | | | This is probably better than recommending Administrator access. Change-Id: Ic916f15fe03f7fa1e03c685265b4774bfc1279c2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/563581 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* project: don't re-shallow manually unshallowed repos during syncLucas Tanure2026-03-201-0/+9
| | | | | | | | | | | | | | | | | | If a user has manually unshallowed a repo (e.g. via `git fetch --unshallow`), the absence of the `shallow` file in the gitdir indicates a full clone. Re-applying depth during a subsequent sync would undo the user's intent. Skip re-shallowing in this case by clearing depth when the project is not new and no shallow file is present. Change-Id: I4ee0e78018de9078fe1bd77a9615613ef0c40d33 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/558743 Reviewed-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Carlos Fernandez <carlosfsanz@meta.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Lucas Alves <ltanure@gmail.com> Tested-by: Lucas Alves <ltanure@gmail.com> Reviewed-by: Lucas Alves <ltanure@gmail.com>
* Use git_superproject.UseSuperproject() everywhereJacky Liu2026-03-183-8/+30
| | | | | | | | | | | | | | | | | | | | Currently somewhere use git_superproject.UseSuperproject(), which checks both the manifest config and user's config, and otherwhere use manifest.manifestProject.use_superproject, which only checks the manifest config. This causes Inconsistent behaviors for users who do not set --use-superproject when doing repo init but have repo.superprojectChoice in their git config. Replace where using manifest.manifestProject.use_superproject with git_superproject.UseSuperproject() to respect user's config and avoid inconsistency. Bug: 454514213 Change-Id: I1f734235cdd67b8a6915f1d05967d1aaa4d03f2a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/561801 Commit-Queue: Jacky Liu <qsliu@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Jacky Liu <qsliu@google.com>
* pydev: drop Python 2 referenceMike Frysinger2026-03-181-1/+0
| | | | | | | | | | | Not sure who uses this anymore, but might as well delete obviously wrong content. Change-Id: I5cdf1cf699c81b7db32b400f371134d21f474743 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/563161 Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* isort: merge config into pyproject.tomlMike Frysinger2026-03-182-41/+24
| | | | | | | | Change-Id: I3a50de04897789c7b2f291882faf1c862645b054 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/563141 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>