diff options
author | Mike Frysinger <vapier@google.com> | 2019-11-11 05:10:03 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2019-11-12 23:14:28 +0000 |
commit | b610b850ac2d791e193383dd77501565fca60aa4 (patch) | |
tree | dd6625a8fb26a315aadfedb25cba3f776a650400 /project.py | |
parent | dff919493aae85d2462b614c9cb4eedeb23fdb96 (diff) | |
download | git-repo-b610b850ac2d791e193383dd77501565fca60aa4.tar.gz |
sync: add sanity check for local checkouts missing network
If you run `repo sync -l foo` without first `repo sync -n foo`,
repo sets up an invalid gitdir tree that gets wedged and requires
manual recovery. Add a sanity check to abort cleanly first.
Change-Id: Iad865ea860a3f1fd2f39ce683fe66bd4380745a5
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/244732
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'project.py')
-rwxr-xr-x | project.py | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1499,6 +1499,13 @@ class Project(object): | |||
1499 | """Perform only the local IO portion of the sync process. | 1499 | """Perform only the local IO portion of the sync process. |
1500 | Network access is not required. | 1500 | Network access is not required. |
1501 | """ | 1501 | """ |
1502 | if not os.path.exists(self.gitdir): | ||
1503 | syncbuf.fail(self, | ||
1504 | 'Cannot checkout %s due to missing network sync; Run ' | ||
1505 | '`repo sync -n %s` first.' % | ||
1506 | (self.name, self.name)) | ||
1507 | return | ||
1508 | |||
1502 | self._InitWorkTree(force_sync=force_sync, submodules=submodules) | 1509 | self._InitWorkTree(force_sync=force_sync, submodules=submodules) |
1503 | all_refs = self.bare_ref.all | 1510 | all_refs = self.bare_ref.all |
1504 | self.CleanPublishedCache(all_refs) | 1511 | self.CleanPublishedCache(all_refs) |