Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Fix switching manifest branches using repo init -b
Browse files Browse the repository at this point in the history
See repo issue #46 :
	https://code.google.com/p/git-repo/issues/detail?id=46

When using repo init -b on an already existing repository,
the next sync will try to rebase changes coming from the old manifest
branch onto the new, leading in the best case scenario to conflicts
and in the worst case scenario to an incorrect "mixed up" manifest.

This patch fixes this by deleting the "default" branch in the local
manifest repository when the -d init switch is used, thus forcing
repo to perform a fresh checkout of the new manifest branch

Change-Id: I379e4875ec5357d8614d1197b6afbe58f9606751
  • Loading branch information
ey3ball authored and spearce committed Jun 13, 2012
1 parent 475a47d commit 5d01650
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions project.py
Expand Up @@ -2167,6 +2167,22 @@ def PreSync(self):
self.revisionExpr = base
self.revisionId = None

def MetaBranchSwitch(self, target):
""" Prepare MetaProject for manifest branch switch
"""

# detach and delete manifest branch, allowing a new
# branch to take over
syncbuf = SyncBuffer(self.config, detach_head = True)
self.Sync_LocalHalf(syncbuf)
syncbuf.Finish()

return GitCommand(self,
['branch', '-D', 'default'],
capture_stdout = True,
capture_stderr = True).Wait() == 0


@property
def LastFetch(self):
try:
Expand Down
3 changes: 3 additions & 0 deletions subcmds/init.py
Expand Up @@ -187,6 +187,9 @@ def _SyncManifest(self, opt):
shutil.rmtree(m.gitdir)
sys.exit(1)

if opt.manifest_branch:
m.MetaBranchSwitch(opt.manifest_branch)

syncbuf = SyncBuffer(m.config)
m.Sync_LocalHalf(syncbuf)
syncbuf.Finish()
Expand Down

0 comments on commit 5d01650

Please sign in to comment.