summaryrefslogtreecommitdiffstats
path: root/project.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Add envar to replace shallow clones with partialJason Chang2023-05-251-0/+30
| | | | | | | | | | | | | | | | An investigation go/git-repo-shallow shows a number of problems when doing a shallow git fetch/clone. This change introduces an environment variable REPO_ALLOW_SHALLOW. When this environment variable is set to 1 during a repo init or repo sync all shallow git fetch commands are replaced with partial fetch commands. Any shallow repository needing update is unshallowed. This behavior continues until a subsequent repo sync command is run with REPO_ALLOW_SHALLOW set to 1. Bug: b/274340522 Change-Id: I1c3188270629359e52449788897d9d4988ebf280 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/374754 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Tested-by: Jason Chang <jasonnc@google.com>
* project: Include tags option during fetch retryNasser Grainawi2023-05-251-0/+1
| | | | | | | | | | | | | | If the original fetch attempt did not want tags, we should continue to honor that when doing a retry fetch with depth set to None. This seems to match the intent of the retry based on the inline comment and results in a significant performance improvement when the original fetch-by-sha1 fails due to the server not allowing requests for unadvertised objects. Change-Id: Ia26bb31ea9aecc4ba2d3e87fc0c5412472cd98c4 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/374918 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Kaushik Lingarkar <kaushik.lingarkar@linaro.org> Tested-by: Kaushik Lingarkar <kaushik.lingarkar@linaro.org>
* upload: Add `--no-follow-tags` by default to git pushAravind Vasudevan2023-04-051-0/+6
| | | | | | | | | | | Gerrit does not accept pushing git tags to CLs. Hence, this change disables push.followTags for repo upload. Fixed: b/155095555 Change-Id: I8d99eac29c0b4b375bdb857ed063914441026fa1 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/367736 Tested-by: Aravind Vasudevan <aravindvasudev@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
* Format codebase with black and check formatting in CQGavin Mak2023-03-221-3705/+4169
| | | | | | | | | | | | Apply rules set by https://gerrit-review.googlesource.com/c/git-repo/+/362954/ across the codebase and fix any lingering errors caught by flake8. Also check black formatting in run_tests (and CQ). Bug: b/267675342 Change-Id: I972d77649dac351150dcfeb1cd1ad0ea2efc1956 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/363474 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* project: clean up error messageLaMont Jones2023-02-011-6/+8
| | | | | | | | | | | Superproject update failures on single-manifest checkouts had an extra space. Bug: b/254523816 Change-Id: I6f71e42337e324a6975c5d6bba487f83abaf054f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/357056 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Xin Li <delphij@google.com>
* Fix flake8 warnings for some filesSergiy Belozorov2023-01-051-2/+6
| | | | | | | Change-Id: If67f8660cfb0479f0e710b3566285ef401fcf077 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/355969 Tested-by: Sergiy Belozorov <sergiyb@chromium.org> Reviewed-by: Mike Frysinger <vapier@google.com>
* Fix ManifestProject.partial_clone_exclude property.Joanna Wang2022-12-021-1/+1
| | | | | | | | | | Bug: b/256358360 Change-Id: Ic6e3a049aa38827123d0324c8b14157562c5986e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353574 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Joanna Wang <jojwang@google.com> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
* sync: clear preciousObjects when set in error.LaMont Jones2022-11-031-1/+1
| | | | | | | | | | | | | | If this is a project that is not using object sharing (there is only one copy of the remote project) then clear preciousObjects. To override this for a project, run: git config --replace-all repo.preservePreciousObjects true Change-Id: If3ea061c631c5ecd44ead84f68576012e2c7405c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/350235 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* Set tracing to always on and save to .repo/TRACE_FILE.Joanna Wang2022-11-031-11/+11
| | | | | | | | | | | | - add `--trace_to_stderr` option so stderr will include trace outputs and any other errors that get sent to stderr - while TRACE_FILE will only include trace outputs piggy-backing on: https://gerrit-review.googlesource.com/c/git-repo/+/349154 Change-Id: I3895a84de4b2784f17fac4325521cd5e72e645e2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/350114 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Joanna Wang <jojwang@google.com>
* project: Add a missing call to _CopyAndLinkFilesPeter Kjellerstedt2022-09-201-0/+2
| | | | | | | | | | | | | If a file that is copied using a <copyfile> tag is modified and not committed or if it is committed to a detached head, then running `repo sync` would update the target file as expected. However, if the modified file is committed to a local branch, then running `repo sync' would not update the target file as expected. Change-Id: Ic98e37d1c2e51fd1bf15abf149c7d06190cfd6d2 Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/344475 Reviewed-by: Mike Frysinger <vapier@google.com>
* sync: use namedtuples for internal return valuesLaMont Jones2022-09-191-8/+19
| | | | | | | | | | | | | Replace tuple returns with namedtuples, to simplify adding new fields. Extend the Sync_NetworkHalf return value to: - success: True if successful (the former return value) - remote_fetched: True if we called `git fetch` Change-Id: If63c24c2f849523f77fa19c05bbf23a5e9a20ba9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/344534 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* Revert "project: initialize new manifests in temp dirs"LaMont Jones2022-09-081-37/+5
| | | | | | | | | | | This reverts commit 07d21e6bde9bd7efdfb8f25f2ed23f023daa5c1f. Reason for revert: crbug.com/gerrit/16230, b/244467766 - breaks aosp-master-with-phones case Change-Id: Id967d92f8622c2c13356b09e46ece9f20040aabc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/344314 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Xin Li <delphij@google.com>
* project: initialize new manifests in temp dirsMike Frysinger2022-08-221-5/+37
| | | | | | | | | | | | | | | | | | | | | | If initializing the manifest fails for any reason, don't leave it in a half complete state. This can cause problems if/when the user tries to reinit because different codepaths will be taken. For example, if we initialize manifests.git and don't finish probing the remote to see what default branch it uses, we end up always using "master" even if that isn't what the remote uses. To avoid all of this, use .tmp dirs when initializing, and rename to the final path only after we complete all the right steps. We should roll this out to all projects we clone, but start with the manifest project for now. Bug: https://crbug.com/gerrit/13526 Bug: https://crbug.com/gerrit/15805 Change-Id: I0214338de69ee11e090285c6b0b211052804af06 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/343539 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* add a few more docs to existing funcsMike Frysinger2022-08-181-0/+11
| | | | | | | Change-Id: I27317a59aba67c05ca1fd333e8f064c0edccb209 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/343185 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* start: do not swallow git output all the timeMike Frysinger2022-08-181-8/+2
| | | | | | | | | | | | Normally git produces no output when creating or switching branches. If there's a problem though, we want to show that to the user. So switch from capturing all output to running in quiet mode. Bug: https://crbug.com/gerrit/15819 Change-Id: I7873ecc7c3bacce591899cc9471cb0244eb74541 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/343454 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* project: simplify GetRemote a bitMike Frysinger2022-08-171-11/+15
| | | | | | | | | | We almost always use self.remote.name when calling self.GetRemote, so make that the default to simplify the code a bit. Change-Id: Ifdf6e1370d6b8963b44e6d384b0fac8fa5c4f2ba Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/343184 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: LaMont Jones <lamontjones@google.com>
* upload: Add ready flag to remove wipWilliam Escande2022-08-031-0/+5
| | | | | | | | | | | The `--wip` allow to bulk push changed as work-in-progress. This CL intend to allow the opposite opperation by removing the wip mark on the CL and set it to be ready to review Change-Id: If0743c5b14829f77be2def5a8547060d06a5648c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/342214 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: William Escande <wescande@google.com>
* status, diff: display correct path for multi-manifestLaMont Jones2022-07-141-19/+24
| | | | | | | | | | | | | | Display the project path relative to the outermost manifest by default, and relative to the sub manifest only when --this-manifest-only is specified. For project-related diagnostic messages, use the outermost manifest for messages. Change-Id: I4537d7dd412a2c182e77d6720e95c1b0ef70eb0e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/340754 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
* project: simplify if-statementMartin Geisler2022-07-111-4/+1
| | | | | | | Change-Id: I05e4505b45963fe6e85cf74a669afafd00fc83c0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/340457 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Martin Geisler <mgeisler@google.com>
* upload: add ‘--ignore-untracked-files’ optionMartin Geisler2022-07-111-2/+6
| | | | | | | | | | | | | | This option will suppress the Uncommitted changes in ... (did you forget to amend?) prompt when there are untracked (unknown) files in the working copy. The prompt is still shown if tracked files are modified. Change-Id: Ia3fcc82989b7fad09b69214eda31e2d0dfc14600 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/340456 Tested-by: Martin Geisler <mgeisler@google.com> Reviewed-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-081-4/+7
| | | | | | | | | | | | 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-261-0/+61
| | | | | | | | | | | | | 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-261-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-211-0/+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>
* 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-291-2/+3
| | | | | | | | | | | 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-211-0/+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>
* Override the manifest for the entire commandLaMont Jones2022-04-191-1/+1
| | | | | | | | | | | 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>
* 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>
* manifest_xml: use Superproject to hold XML contentv2.23LaMont Jones2022-04-121-1/+0
| | | | | | | | | | | | | | | 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>
* manifest_xml: Add Load and Unload methodsLaMont Jones2022-04-081-13/+14
| | | | | | | | | | | | - 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-061-51/+54
| | | | | | | | | 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-061-3/+97
| | | | | | | | | 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-061-17/+91
| | | | | | | | | 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-011-0/+289
| | | | | | | | | 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-311-28/+31
| | | | | | | | | | 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>
* Add multi-manifest support with <submanifest> elementv2.22LaMont Jones2022-02-171-15/+26
| | | | | | | | | | | 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>
* 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-261-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* project: store objects in project-objects directlyMike Frysinger2022-01-191-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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-071-11/+27
| | | | | | | | | | | | | 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>
* 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>