diff options
author | Dan Willemsen <dwillemsen@google.com> | 2015-10-07 16:53:10 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2016-02-04 14:31:55 -0800 |
commit | 04197a5144d6a40ee2d85799b32505250480f365 (patch) | |
tree | a44651e81b1b56c999e57ccc1c540e841118f76e /subcmds/start.py | |
parent | 745b4ad660f8050045b521c4e15b7d3ac0b3d70e (diff) | |
download | git-repo-04197a5144d6a40ee2d85799b32505250480f365.tar.gz |
GITC: Fix 'repo start <branch> <repo>/<subdir>'
As soon as we wrote the gitc manifest, the folder for that repo became
empty, causing the next GetProjects lookup to fail. Reorder the
GetProjects calls so that they all happen while we still have the
repository contents available.
If you were already in a subdir, for cases like 'repo start <branch> .',
this would still fail, since the working directory would disappear out
from under you. That's fine most of the time, since we shouldn't be
doing operations based on the local directory, but git has a realpath
function that tries to restore CWD by chdir'ing back to it. So if the
working directory no longer exists, chdir to the topdir before
continuing.
Change-Id: Ibdf6cd37ff6e5a5f8338347c3919175491f7166f
Diffstat (limited to 'subcmds/start.py')
-rw-r--r-- | subcmds/start.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/subcmds/start.py b/subcmds/start.py index 940c3413..d1430a9d 100644 --- a/subcmds/start.py +++ b/subcmds/start.py | |||
@@ -57,10 +57,15 @@ revision specified in the manifest. | |||
57 | print("error: at least one project must be specified", file=sys.stderr) | 57 | print("error: at least one project must be specified", file=sys.stderr) |
58 | sys.exit(1) | 58 | sys.exit(1) |
59 | 59 | ||
60 | all_projects = self.GetProjects(projects, | ||
61 | missing_ok=bool(self.gitc_manifest)) | ||
62 | |||
63 | # This must happen after we find all_projects, since GetProjects may need | ||
64 | # the local directory, which will disappear once we save the GITC manifest. | ||
60 | if self.gitc_manifest: | 65 | if self.gitc_manifest: |
61 | all_projects = self.GetProjects(projects, manifest=self.gitc_manifest, | 66 | gitc_projects = self.GetProjects(projects, manifest=self.gitc_manifest, |
62 | missing_ok=True) | 67 | missing_ok=True) |
63 | for project in all_projects: | 68 | for project in gitc_projects: |
64 | if project.old_revision: | 69 | if project.old_revision: |
65 | project.already_synced = True | 70 | project.already_synced = True |
66 | else: | 71 | else: |
@@ -70,8 +75,10 @@ revision specified in the manifest. | |||
70 | # Save the GITC manifest. | 75 | # Save the GITC manifest. |
71 | gitc_utils.save_manifest(self.gitc_manifest) | 76 | gitc_utils.save_manifest(self.gitc_manifest) |
72 | 77 | ||
73 | all_projects = self.GetProjects(projects, | 78 | # Make sure we have a valid CWD |
74 | missing_ok=bool(self.gitc_manifest)) | 79 | if not os.path.exists(os.getcwd()): |
80 | os.chdir(self.manifest.topdir) | ||
81 | |||
75 | pm = Progress('Starting %s' % nb, len(all_projects)) | 82 | pm = Progress('Starting %s' % nb, len(all_projects)) |
76 | for project in all_projects: | 83 | for project in all_projects: |
77 | pm.update() | 84 | pm.update() |