summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* man: regenerateMike Frysinger2022-07-1128-31/+473
| | | | | | | Change-Id: I3ca8ca8f502605b194ebe65b315eda08c51592a6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/340494 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* Fix Projects.shareable_dirsv2.27LaMont Jones2022-06-081-2/+16
| | | | | | | | | | | | If this tree is not using alternates for object sharing, then we need to continue to call it a shared directory. Bug: https://bugs.chromium.org/p/gerrit/issues/detail?id=15982 Test: manual Change-Id: I1750f10b192504ac67f552222f8ddb9809d344fe Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/338974 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* Only sync superproject if it will be used.LaMont Jones2022-06-085-20/+71
| | | | | | | | | | | | If the user says `--no-use-superproject`, then do not bother syncing the superproject. Also add/update docstrings and comments throughout. Change-Id: I9cdad706130501bab9a22d3099a1dae605e9c194 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/338975 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* sync: add multi-manifest supportv2.26LaMont Jones2022-05-265-107/+247
| | | | | | | | | | | | | With this change, partial syncs (sync with a project list) are again supported. If the updated manifest includes new sub manifests, download them inheriting options from the parent manifestProject. Change-Id: Id952f85df2e26d34e38b251973be26434443ff56 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334819 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* project: initial separation of shared project objectsMike Frysinger2022-05-262-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For now, this is opt-in via environment variables: - export REPO_USE_ALTERNATES=1 The shared project logic that shares the internal .git/objects/ dir directly between multiple projects via the project-objects/ tree has a lot of KI with random corruption. It all boils down to projects sharing objects/ but not refs/. Git operations that use refs to see what objects are reachable and discard the rest can easily discard objects that are used by other projects. Consider this project layout: <show fs layout> There are unique refs in each of these trees that are not visible in the others. This means it's not safe to run basic operations like git prune or git gc. Since we can't share refs (each project needs to have unique refs like HEAD in order to function), let's change how we share objects. The old way involved symlinking .git/objects/ to the project-objects tree. The new way shares objects using git's info/alternates. This means project-objects/ will only contain objects that exist in the remote project. Local per-project objects (like when creating branches and making changes) will never be shared. When running a prune or gc operation in the per-project state, it will only ever repack or discard those per-project objects. The common shared objects would only be cleaned up when running a common operation (i.e. by repo itself). One downside to this for users is if they try blending unrelated upstream projects. For example, in CrOS we have multiple kernel projects (for diff versions) checked out. If a dev fetched the upstream Linus tree into one of them, the objects & tags would not be shared with the others, so they would have to fetch the upstream state for each project. Annoying, but better than the current corruption situation we're in now. Also if the dev runs a manual `git fetch` in the per-project to sync it up to newer state than the last `repo sync` they ran, the objects would get duplicated. However, git operations later on should eventually dedupe this. Bug: https://crbug.com/gerrit/15553 Change-Id: I313a9b8962f9d439ef98ac0ed37ecfb9e0b3864e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328101 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* upload: move label validation to core functionMike Frysinger2022-05-212-6/+8
| | | | | | | | | This way we know we don't need to encode the labels. Change-Id: Ib83ed8f4ed05f00b9d2d06a9dd3f304e4443430e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/337518 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: LaMont Jones <lamontjones@google.com>
* tests: switch to tempfile.TemporaryDirectoryMike Frysinger2022-05-204-40/+20
| | | | | | | | | | Now that we don't need to support Python 2, we can switch to this API for better contextmanager logic. Change-Id: I2d03e391121886547e7808a3b5c3b470c411533f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/337515 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: fix --use-superproject logic for init.LaMont Jones2022-05-201-4/+4
| | | | | | | | | | | | | | If init was run with --use-superproject, init failed. If init was run without --{no,}use-superproject option then manifests with <superproject/> elements were mishandled. Bug: b/233226285 Test: manual Change-Id: I737e71c89d2d7c324114f58bf2dc82b40e5beba7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/337534 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* manifest: add submanifest.default_groups attributev2.25LaMont Jones2022-04-294-14/+39
| | | | | | | | | | | When the user does not specify any manifest groups, this allows the parent manifest to indicate which manifest groups should be used for syncing the submanifest. Change-Id: I88806ed35013d13dd2ab3cd245fcd4f9061112c4 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/335474 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* project: Do not exit early on --standalone-manifest.LaMont Jones2022-04-291-34/+33
| | | | | | | | | | | | After we successfully download the standalone manifest file, we cannot exit early. Bug: https://bugs.chromium.org/p/gerrit/issues/detail?id=15861 Change-Id: Ic47c9f7e9921851f94c6f24fd82b896eff524037 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/335974 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* project: Add missing importsv2.24.1LaMont Jones2022-04-212-2/+1
| | | | | | | | | | | Some imports were missed when moving manifestProject to project.py Bug: https://bugs.chromium.org/p/gerrit/issues/detail?id=15861 Change-Id: Id8fffeaa3f88f344a13b5ab44e5403c7edd98f31 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/335554 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com>
* progress: optimize progress bar updates a bitv2.24Mike Frysinger2022-04-191-11/+16
| | | | | | | | | | | | | Rather than erase the entire line first then print out the new content, print out the new content on top of the old and then erase anything we didn't update. This should result in a lot less flashing with faster terminals. Bug: https://crbug.com/gerrit/11293 Change-Id: Ie2920b0bf3d5e6f920b8631a1c406444b23cd12d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/335214 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* Override the manifest for the entire commandLaMont Jones2022-04-193-55/+71
| | | | | | | | | | | When a manifest file is overridden, remember that and keep using the override for the remainder of the process. If we need to revert it, make the override name evaluate False. Change-Id: I1eee05fec6988c1ee4a3c751c4b540d5b5d11797 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/335136 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* sync: refactor use of self.manifestLaMont Jones2022-04-142-69/+83
| | | | | | | | | | | We need to iterate over multiple manifests, and generally use the outer_client.manifest for multi-manifest support. This refactors the use of self.manifest into a chosen manifest. Change-Id: I992f21d610c929675e99555ece9c38df4b635839 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334699 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* Stop passing optparse.Values to git_superprojectLaMont Jones2022-04-143-10/+25
| | | | | | | | | | | | | | Make git_superproject independent of the command line by passing the specific value instead of requiring the caller to have an optparse.Values object to pass in. Flag --use-superproject and --archive as incompatible in subcmds/init.py Change-Id: Ied7c874b312e151038df903c8af4328f070f387c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/335135 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* ManifestProject: add manifest_platformLaMont Jones2022-04-141-14/+20
| | | | | | | | | | | And fix most of the other attributes to return the value instead of None. Change-Id: Iddcbbeb56238ee082bb1cae30adbd27a2f551f3d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/335134 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Xin Li <delphij@google.com>
* forall: fix multi-manifest variables.LaMont Jones2022-04-141-2/+8
| | | | | | | | | | | | | - REPO_PATH is relative to the root of the client. REPO_OUTERPATH is not needed. - REPO_INNERPATH is relative to the sub manifest root. - REPO_OUTERPATH is the path for the sub manifest root relative to the root of the client. Change-Id: I031692891cfef2634d1358584d27a6a4df735c20 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334899 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* git_superproject: only print beta notice once.LaMont Jones2022-04-141-2/+9
| | | | | | | | | This eliminates duplicate notices during multi-manifest syncs. Change-Id: Idcb038ddeb363368637c58c11346ebf8fd2b27ac Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334939 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* manifest_xml: use Superproject to hold XML contentv2.23LaMont Jones2022-04-127-117/+125
| | | | | | | | | | | | | | | Always create Superproject when there is a <superproject> tag, and have it hold the XML content, similar to how other manifest elements are handled. This also adds SetQuiet and SetPrintMessages to Superproject consistent with manifest.SetUseLocalManifests. Change-Id: I522bf3da542006575799f0640c67f7052704f266 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334641 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* sync: respect `sync-c` manifest optionDaniel Andersson2022-04-082-2/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation states that a `sync-c` attribute in the manifest file can set a default for whether only the current branch should be fetched or all branches. This seems to have been broken for some time. Commit 7356114 introduced the `--no-current-branch` CLI option and relied on getting `None` via `optparse` if neither `--current-branch` nor `--no-current-branch` was set to distinguish it from a boolean value. If `None` was received, it would read the value from the manifest option `sync-c`. The parsing went through the utility function `_GetCurrentBranchOnly` which returned `True` if `--current-branch` had been given on the command-line, or fell back on the "superproject" setting, which would either return `True` or `None`. This would incorrectly make `repo` fall back to the manifest setting even if the user had given `--no-current-branch` if no superproject was requested -- the manifest became "too powerful": Command-line Using superproject → `current_branch_only` ------------ ------------------ ----------------------- No From manifest Yes True --current-branch No True --current-branch Yes True --no-current-branch No From manifest ← wrong --no-current-branch Yes True In commit 0cb6e92 the superproject configuration value reading changed from something that could return `None` to something that always returned a boolean. If it returned `False`, this would then incorrectly make `repo` ignore the manifest option even if neither `--current-branch` nor `--no-current-branch` had been given. The manifest default became useless: Command-line Using superproject → `current_branch_only` ------------ ------------------ ----------------------- No False ← wrong Yes True --current-branch No True --current-branch Yes True --no-current-branch No False --no-current-branch Yes True By swapping the order in which the command-line option target and the superproject setting is evaluated, things should work as documented: Command-line Using superproject → `current_branch_only` ------------ ------------------ ----------------------- No From manifest Yes True --current-branch No True --current-branch Yes True --no-current-branch No False --no-current-branch Yes True Change-Id: I933c232d2fbecc6b9bdc364ebac181798bce9175 Tested-by: Daniel Andersson <daniel.r.andersson@volvocars.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334270 Reviewed-by: Mike Frysinger <vapier@google.com>
* manifest_xml: Add Load and Unload methodsLaMont Jones2022-04-083-19/+31
| | | | | | | | | | | | - do not call the internal method from subcmds/sync.py. - use the correct default groups for submanifests. - only sync the superproject when we are told to. Change-Id: I81e4025058f1ee564732b9e17aecc522f6b5f626 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334639 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* Fix sub manifest handlingLaMont Jones2022-04-063-55/+60
| | | | | | | | | Also fixes some typos Change-Id: Id2ba5834ba3a74ed3f29c36d2c0030737dc63e35 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334579 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* init: add multi-manifest supportLaMont Jones2022-04-062-41/+100
| | | | | | | | | This moves more of the manifest project handling into ManifestProject. Change-Id: Iecdafbec18cccdfd8e625753c3bd1bcddf2b227f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334520 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* Move manifest config logic into ManifestProjectLaMont Jones2022-04-065-34/+107
| | | | | | | | | Use ManifestProject properties for config values. Change-Id: Ib4ad90b0d9a089916e35615b8058942e6d01dc04 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334519 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* project: add ManifestProject.Sync()LaMont Jones2022-04-012-240/+315
| | | | | | | | | Move the logic to sync a ManifestProject out of subcmds/init.py Change-Id: Ia9d00f3da1dc3c5dada84c4d19cf9802c2346cb0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334140 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* project: Isolate ManifestProject from RepoProjectLaMont Jones2022-03-312-33/+37
| | | | | | | | | | Create RepoProject and ManifestProject, inheriting from MetaProject, with methods separated for isolation and clarity. Change-Id: Ic1d6efc65c99470290fea612e2abaf8670d199f4 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334139 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* manifest_file must be an absolute pathLaMont Jones2022-03-231-1/+8
| | | | | | | | | | | | | | | | Correctly pass the full path of the manifest file for the submanifest. The manifest-name in the <submanifest/> element was being passed in as given, which caused it to not be found since the current directory never set. (b/226333721: fails when manifest-name is given.) Also verify that the manifest_file passed to XmlManifest() is an absolute path. Bug: https://b.corp.google.com/issues/226333721 Change-Id: I23461078233e34562bc2eafeb732cfe8bd38ddc1 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/333861 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* trace: allow writing traces to a socketJosh Steadmon2022-03-162-14/+134
| | | | | | | | | | | | | | | | | | | Git can write trace2 events to a Unix domain socket [1]. This can be specified via Git's `trace2.eventTarget` config option, which we read to determine where to log our own trace2 events. Currently, if the Git config specifies a socket as the trace2 target, we fail to log any traces. Fix this by adding support for writing to a Unix domain socket, following the same specification that Git supports. [1]: https://git-scm.com/docs/api-trace2#_enabling_a_target Change-Id: I928bc22ba04fba603a9132eb055141845fa48ab2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/332339 Reviewed-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Josh Steadmon <steadmon@google.com>
* manifest_xml: group for submanifest projectsLaMont Jones2022-02-282-0/+7
| | | | | | | | | | Add all projects in a submanifest to the group submanifest::<path_prefix> for ease in filtering. Change-Id: Ia6f01f9445f4f8d20fda3402f4d5821c43ceaf7f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/331319 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* Add multi-manifest support with <submanifest> elementv2.22LaMont Jones2022-02-1728-165/+797
| | | | | | | | | | | To be addressed in another change: - a partial `repo sync` (with a list of projects/paths to sync) requires `--this-tree-only`. Change-Id: I6c7400bf001540e9d7694fa70934f8f204cb5f57 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/322657 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* Move local-manifest check to manifest_xml.pyLaMont Jones2022-02-152-2/+7
| | | | | | | | | | This removes the need for git_superproject to include manifest_xml, and puts the logic for local_manifest detection in one place. Change-Id: I4d33ded0542ceea4606a1ea24304f678de20c59e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/330499 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com>
* project.py: pass --recurse-submodules={value}LaMont Jones2022-02-101-2/+1
| | | | | | | | | | If submodules is False, explicitly pass '=no'. Uninitialized submodules may cause the default option to fail. Change-Id: Ia00bcba5b69c4b65195f4c469c686a3ef9a4a3ad Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/330159 Reviewed-by: Xin Li <delphij@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* project: mark gc.log as safe to discard when migrating .git/v2.21Mike Frysinger2022-01-261-1/+2
| | | | | | | | | | | | This is just a log file that, while useful for humans when gc aborts, doesn't contain any data, so it's safe to throw away. Bug: https://crbug.com/gerrit/15619 Change-Id: Ia95e0e281f52260668f7a80b5d5f990e32a8597a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328999 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* init: add an option --enable-git-lfs-filterXD Trol2022-01-265-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | It was reported that git-lfs did not work with git-repo. Specifically, `git read-tree -u` run by `repo sync` would fail git-lfs's smudge filter. See https://github.com/github/git-lfs/issues/1422. In fact, by the time `git read-tree -u` is run, the repository is not bare. It is just that, the working directory is not the same as the .git directory. git-lfs's filter should work. No one seems to have delved into that issue. Today, with newer versions of git-repo and git-lfs, that issue will not reproduce. Tested with - git 2.33, git-lfs 2.13 on macOS - git 2.17, git-lfs 2.3 on ubuntu So, it seems fine to add an option --enable-git-lfs-filter, default to false, and stat that it may not work with older versions of git and git-lfs in the help doc. Bug: https://crbug.com/gerrit/14516 Change-Id: I8d21854eeeea541e072f63d6b10ad1253b1a9826 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328359 Tested-by: XD Trol <milestonejxd@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com>
* init: make bad --repo-rev settings more clearMike Frysinger2022-01-252-2/+7
| | | | | | | | | | | | | | | | If the user passes a bad --repo-rev setting in a new checkout, add a tip to the error message that their option is probably bad instead of just saying "unable to resolve". If the user has already initialized a checkout, we'd display a raw traceback which would confuse them. Swallow that and also include the --repo-rev tip. Bug: https://crbug.com/gerrit/15610 Change-Id: I5d72513c7b37bf9bb5d19862fcdfaf0d1f44e886 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328820 Reviewed-by: Jack Neus <jackneus@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: Ignore failure to remove the sample hooksPeter Kjellerstedt2022-01-221-1/+4
| | | | | | | | | | Removing the sample hooks is just clean up, so if repo cannot remove a sample hook that should not cause it to fail. Change-Id: I716b977da091c22b8f53e134f4fbc114116f9a65 Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328635 Reviewed-by: Mike Frysinger <vapier@google.com>
* branches: Fix "not in" handlingLaMont Jones2022-01-211-3/+3
| | | | | | | | | | | | | | If the branch is current, or present in less than half of the projects, list which projects it is *in*. Otherwise, correctly detect which projects (by relpath) it is not in. Previously, the "not in" path would incorrectly list all projects. Change-Id: Ia153856f577035a51f538b7bf5d3135b70c69d52 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328199 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Xin Li <delphij@google.com>
* project: store objects in project-objects directlyMike Frysinger2022-01-192-7/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to stop sharing objects/ directly between shared projects, we have to fetch the remote objects into project-objects/ manually. So instead of running git operations in the individual project dirs and relying on .git/objects being symlinked to project-objects/, tell git to store any objects it fetches in project-objects/. We do this by leveraging the GIT_OBJECT_DIRECTORY override. This has been in git forever, or at least since v1.7.2 which is what we already hard require. This tells git to save new objects to the specified path no matter where it's being run otherwise. We still otherwise run git in the project-specific dir so that it can find the right set of refs that it wants to compare against, including local refs. For that reason, we also have to leverage GIT_ALTERNATE_OBJECT_DIRECTORIES to tell git where to find objects that are not in the upstream remote. This way git doesn't blow up when it can't find objects only associated with local commits. As it stands right now, the practical result is the same: since we symlink the project objects/ dir to the project-objects/ tree, the default objects dir, the one we set $GIT_OBJECT_DIRECTORY to, and the one we set $GIT_ALTERNATE_OBJECT_DIRECTORIES to are actually all the same. So this commit by itself should be safe. But in a follow up commit, we can replace the symlink with a separate dir and git will keep working. Bug: https://crbug.com/gerrit/15553 Change-Id: Ie4e654aec3e1ee307eee925a54908a2db6a5869f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328100 Reviewed-by: Jack Neus <jackneus@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: move --reference handling to project-objectsMike Frysinger2022-01-131-5/+5
| | | | | | | | | | | | | | | | | When using --reference, the path is written to objects/info/alternates. The path is accessed inconsistently -- sometimes through projects/ (via self.gitdir) and sometimes through project-objects/ (via self.objdir). This works because projects/.../objects is a symlink to the objects dir under project-objects/. Change all accesses to go through self.objdir. This will allow us to stop symlinking projects/.../objects without the reference dir logic breaking. The projects/ path is going to use its alternates file for its own needs. Bug: https://crbug.com/gerrit/15553 Change-Id: I6b452ad1aaffec74ecb7ac1bb9baa3a3a52e076c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328099 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jack Neus <jackneus@google.com>
* test_project: use os.readlink instead of Path.readlinkSebastian Wagner2022-01-111-1/+1
| | | | | | | | | | | Path.readlink is only available on Python 3.9, breaking compatibility with all python versions below. os.readlink is already used in other places of this file, so use it here as well. Change-Id: I5acf8f5334a3e7c8de9cea1939d7e2b9af5f30ae Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/327844 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Sebastian Wagner <sebix@sebix.at>
* project: prune sample hooksv2.20Mike Frysinger2022-01-101-0/+5
| | | | | | | | | | These hooks are never used and often get stale, so just trim them. Users rarely look in these dirs to begin with. Change-Id: Ic785aa55fb7ec84a61376df101127d0018882030 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/327538 Reviewed-by: Jack Neus <jackneus@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: drop support for symlinking internal .git filesMike Frysinger2022-01-101-12/+2
| | | | | | | | | | | Since we don't do this anymore, and there prob won't be a need to bring it back, drop support for it. Bug: https://crbug.com/gerrit/15460 Change-Id: I7d86706f108c797a5c7962cb1578693d49430367 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/327537 Reviewed-by: Jack Neus <jackneus@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: abort a bit earlier before migrating .git/Mike Frysinger2022-01-072-13/+53
| | | | | | | | | | | | | Verify all the .git/ paths will be handled by the migration logic before starting the migration. This way we still abort & log an error, but the user gets to see it before we put the tree into a state that they have to manually recover. Also add a few more known-safe-to-clobber paths. Bug: https://crbug.com/gerrit/15273 Change-Id: If49d69b341bc960ddcafa30da333fb5ec7145b51 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/327557 Reviewed-by: Colin Cross <ccross@android.com> Tested-by: Mike Frysinger <vapier@google.com>
* Revert "sync: dropped "NOTICE: --use-superproject is in beta ..." message."Raman Tenneti2022-01-061-0/+2
| | | | | | | | | | | | | | | | | This reverts commit d53cb9549a0c57939b12c5c35a6b581aec2ca36f. As long as repo's reference docs treat this feature as a work in progress and don't cover it well enough to allow all repo maintainers to easily support it, it is inconsistent to report to users that it is no longer in beta. Thanks for vapier@google.com for noticing. https://crbug.com/gerrit/15527 tracks the required documentation changes before we'd be ready to roll forward again. Change-Id: Ic9bd951cfb3c1abf6e1bfa30dfe4afa1c9b7bec6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/327337 Reviewed-by: Jonathan Nieder <jrn@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Jonathan Nieder <jrn@google.com>
* project: stop symlinking info dir under .git/Mike Frysinger2022-01-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unsharing this directory shouldn't be a problem. The current repo code treated it as a file, and while that's actually incorrect, files & dirs are basically treated the same, so it's practically the same. Let's enumerate each subpath since there aren't that many. info/refs: Only used when the project is exported over git dumb transports (i.e. a http:// server). Repo never does this, and it's extremely unlikely any user has ever done this. Plus, this proposal talks about unsharing project refs, so this file should get unshared too. info/grafts: A user-configurable file that repo never touches. Might be useful to share across projects, but probably rarely (if ever) used by developers, and forcing them to configure it for each project isn't that big of a deal. info/exclude: info/attributes: User-configurable files that repo never touches. Doesn't seem like most users ever touch these, and if they do, having them do it for each shared project isn't a big deal. info/sparse-checkout: Repo doesn't use sparse checkouts, and it's extremely unlikely to even work if a user tried doing something themselves. Bug: https://crbug.com/gerrit/15460 Change-Id: I53e44d73a6d7a92da615b46600d8ea51cb46e3ac Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/327519 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: stop symlinking description file under .git/Mike Frysinger2022-01-061-1/+1
| | | | | | | | | | | | | | | | Nothing uses this path. It’s only for exporting git dirs e.g. for online gitweb use which probably no one does. It is not the same description file as exists on servers we cloned from. Leaving it as the default plain text file will simplify code. We don't undo any existing symlinks if they exist since repo does not care about them, and their existence doesn't hurt. Bug: https://crbug.com/gerrit/15460 Change-Id: Ic34fe7c3cfb8f6da844de5be30158f59382b1cc8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/327518 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: stop symlinking svn under .git/Mike Frysinger2022-01-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This path only matters to users of `git svn` who manually run it in local projects after they get a full repo client checkout. With svn usage falling in general, and with the fact that the source checkout now symlinks its .git/ state to the internal projects/ path, we don't need to manage this anymore. It means the path won't be shared among multiple local projects that have the same remote, but so it goes. It was an optimization only, not functionality required for correctness. We want to simplify the internals to stop messing with git state, and this particular path doesn't seem worth the effort to maintain. We don't undo any existing svn symlinks if they exist since repo does not care about them, and their existence doesn't hurt anything. Bug: https://crbug.com/gerrit/15460 Change-Id: Ie8496b275bcc589771aa9f4ee874ed2ee6d5241d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/327517 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: clean up now unused codeMike Frysinger2022-01-061-34/+4
| | | | | | | | | | | | | Now that we symlink worktree .git/ paths to .repo/projects/, we never set share_refs=True anywhere, which means all of this logic is dead code. Throw it all away. Do it as a separate commit to make the parent commit easier to review. Bug: https://crbug.com/gerrit/15273 Change-Id: If496d39029d3d3bd523ba24c603ce47a63ad9b51 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/326817 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jack Neus <jackneus@google.com>
* sync: dropped "NOTICE: --use-superproject is in beta ..." message.Raman Tenneti2021-12-291-2/+0
| | | | | | | | | | | | Tested the code with the following commands. $ ./run_tests -v Bug: [google internal] b/209511230 Change-Id: Ia3c6de47709f5276e324a5bb608383aba3b2c562 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/327197 Reviewed-by: Xin Li <delphij@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* sync: With --mirror option, don't display no-use-superproject... message.Raman Tenneti2021-12-071-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | + Display 'Defaulting to no-use-superproject because there is no working tree.' message if --use-superproject option is used and we are not using superproject because manifest is either a mirror or is an archive. Tested the code with the following commands. $ ./run_tests -v Tested the sync code by using repo_dev alias and pointing to this CL. $ repo init -u https://android.googlesource.com/mirror/manifest --mirror $ repo_dev sync Receiving objects: 100% (3/3), done.eiving objects: 33% (1/3) $ repo_dev sync --use-superproject Defaulting to no-use-superproject because there is no working tree. Fetching: 0% (0/2158) warming up Bug: https://crbug.com/gerrit/15368 Change-Id: I16b87ee9623315dbc3100b612b1decdaab7ac1dc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/325797 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>