diff options
author | Julius Gustavsson <juliusb@gmail.com> | 2010-06-17 17:55:02 +0200 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2010-07-15 16:38:08 -0700 |
commit | 0cb1b3f687da4634e431953ef84fee59dd3f5d59 (patch) | |
tree | 86da739f320891f1b8383eb0579d267e550f9a75 /project.py | |
parent | 9e426aa43231073c4a98dae3f6c16d67ab6f3b59 (diff) | |
download | git-repo-0cb1b3f687da4634e431953ef84fee59dd3f5d59.tar.gz |
sync: Try fetching a tag as a last resort before giving up
If a tagged commit is not reachable by the fetch refspec configured
for the git (usually refs/heads/*) it will not be downloaded by
'git fetch'. The tag can however be downloaded with 'git fetch
--tags' or 'git fetch tag <tag>'.
This patch fixes the situation when a tag is not found after a
'git fetch'. Repo will issue 'git fetch tag <tag>' before giving
up completely.
Change-Id: I87796a5e1d51fcf398f346a274b7a069df37599a
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -283,7 +283,7 @@ class Project(object): | |||
283 | return os.path.exists(os.path.join(g, 'rebase-apply')) \ | 283 | return os.path.exists(os.path.join(g, 'rebase-apply')) \ |
284 | or os.path.exists(os.path.join(g, 'rebase-merge')) \ | 284 | or os.path.exists(os.path.join(g, 'rebase-merge')) \ |
285 | or os.path.exists(os.path.join(w, '.dotest')) | 285 | or os.path.exists(os.path.join(w, '.dotest')) |
286 | 286 | ||
287 | def IsDirty(self, consider_untracked=True): | 287 | def IsDirty(self, consider_untracked=True): |
288 | """Is the working directory modified in some way? | 288 | """Is the working directory modified in some way? |
289 | """ | 289 | """ |
@@ -416,7 +416,7 @@ class Project(object): | |||
416 | 416 | ||
417 | try: f = df[p] | 417 | try: f = df[p] |
418 | except KeyError: f = None | 418 | except KeyError: f = None |
419 | 419 | ||
420 | if i: i_status = i.status.upper() | 420 | if i: i_status = i.status.upper() |
421 | else: i_status = '-' | 421 | else: i_status = '-' |
422 | 422 | ||
@@ -601,6 +601,18 @@ class Project(object): | |||
601 | if not self._RemoteFetch(): | 601 | if not self._RemoteFetch(): |
602 | return False | 602 | return False |
603 | 603 | ||
604 | #Check that the requested ref was found after fetch | ||
605 | # | ||
606 | try: | ||
607 | self.GetRevisionId() | ||
608 | except ManifestInvalidRevisionError: | ||
609 | # if the ref is a tag. We can try fetching | ||
610 | # the tag manually as a last resort | ||
611 | # | ||
612 | rev = self.revisionExpr | ||
613 | if rev.startswith(R_TAGS): | ||
614 | self._RemoteFetch(None, rev[len(R_TAGS):]) | ||
615 | |||
604 | if self.worktree: | 616 | if self.worktree: |
605 | self._InitMRef() | 617 | self._InitMRef() |
606 | else: | 618 | else: |
@@ -982,7 +994,7 @@ class Project(object): | |||
982 | 994 | ||
983 | ## Direct Git Commands ## | 995 | ## Direct Git Commands ## |
984 | 996 | ||
985 | def _RemoteFetch(self, name=None): | 997 | def _RemoteFetch(self, name=None, tag=None): |
986 | if not name: | 998 | if not name: |
987 | name = self.remote.name | 999 | name = self.remote.name |
988 | 1000 | ||
@@ -994,6 +1006,9 @@ class Project(object): | |||
994 | if not self.worktree: | 1006 | if not self.worktree: |
995 | cmd.append('--update-head-ok') | 1007 | cmd.append('--update-head-ok') |
996 | cmd.append(name) | 1008 | cmd.append(name) |
1009 | if tag is not None: | ||
1010 | cmd.append('tag') | ||
1011 | cmd.append(tag) | ||
997 | return GitCommand(self, | 1012 | return GitCommand(self, |
998 | cmd, | 1013 | cmd, |
999 | bare = True, | 1014 | bare = True, |