jmollan / git-repo

Automatically exported from code.google.com/p/git-repo
Apache License 2.0
0 stars 0 forks source link

repo init -b <branch> fails #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Reported by Ed Heyl <edheyl@google.com> on Mon Aug 31 10:04:48 PDT 2009
Source: JIRA REPO-46
Environment: Linux: gHardy

JBQ said he saw the same problem externally, and had to do empty merges
between manifests to resolve the issue.

I wasn't sure which branch I 'was' on (master I believe), but I tried to run
'repo init -b donut' to switch to the donut branch, but repo failed with:
repo init -b donut
.repo/manifests/: discarding 49 commits removed from upstream
project .repo/manifests/
First, rewinding head to replay your work on top of it...
Applying: new project
/usr/local/google/src/android-git/.repo/manifests/.git/rebase-apply/patch:13:
trailing whitespace.

warning: 1 line adds whitespace errors.
Applying: Remove spurious whitespace
error: readonly-korg-proprietary-master.xml: does not exist in index
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Renaming readonly-korg-proprietary-master.xml => stage-korg-donut.xml
Auto-merging stage-korg-donut.xml
CONFLICT (rename/modify): Merge conflict in stage-korg-donut.xml
Failed to merge in the changes.
Patch failed at 0002 Remove spurious whitespace

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

fatal: cannot create default in manifest

BUT, as you can see I wasn't even on any branch, repo confused?

android-build@sekiwake:/usr/local/google/src/android-git$ git branch -av
fatal: Not a git repository (or any of the parent directories): .git
android-build@sekiwake:/usr/local/google/src/android-git$ cd .repo/manifests
android-build@sekiwake:/usr/local/google/src/android-git/.repo/manifests$ ls
default.xml  readonly-korg-donut.xml  readonly-korg-proprietary-donut.xml
stage-korg-donut-release.xml  stage-korg-donut.xml
android-build@sekiwake:/usr/local/google/src/android-git/.repo/manifests$
android-build@sekiwake:/usr/local/google/src/android-git/.repo/manifests$
android-build@sekiwake:/usr/local/google/src/android-git/.repo/manifests$
android-build@sekiwake:/usr/local/google/src/android-git/.repo/manifests$
android-build@sekiwake:/usr/local/google/src/android-git/.repo/manifests$
android-build@sekiwake:/usr/local/google/src/android-git/.repo/manifests$ git
branch -av
* (no branch)                        c7fdd2b new project
  default                            f3d8636 new project: platform/external/
proguard.git
  remotes/m/master                   -> origin/master
  remotes/origin/cupcake             fdff64a Add appropriate projects to the
staging area
  remotes/origin/donut               b2c12d3 Remove spurious whitespace
  remotes/origin/donut-release       887e073 new project
  remotes/origin/eclair              83a9499 Manifest for eclair mirror +
proprietary files
  remotes/origin/eclair-plus-aosp    2b66785 Remove unnecessary manifests
  remotes/origin/eclair-release      5888623 reconcile difference between
eclair and eclair-release manifests.
  remotes/origin/icu4c-merge         2674ab4 Manifest that includes the
sandbox for icu4c merges
  remotes/origin/master              f3d8636 new project: platform/external/
proguard.git
  remotes/origin/master-webkit-merge 0279630 Update default.xml to point
frameworks/base and external/webkit to master-webkit-merge.
  remotes/origin/master_gl           032466e merge master in master_gl
  remotes/origin/readonly-p4-donut   db8d2ea Always use FQDN for android-git
  remotes/origin/readonly-p4-master  ab61a73 Always use FQDN for android-git

Original issue reported on code.google.com by code-rev...@gtempaccount.com on 24 Sep 2009 at 9:10

GoogleCodeExporter commented 9 years ago

Original comment by sop+code@google.com on 24 Sep 2009 at 11:06

GoogleCodeExporter commented 9 years ago
Is there any update on this issue?

Today I tried switching manifest branches using repo init -b and I still see 
the same issue:
-----------------------
project .repo/manifests/
First, rewinding head to replay your work on top of it...
Applying: Update the default manifest
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging default.xml
CONFLICT (content): Merge conflict in default.xml
Failed to merge in the changes.
Patch failed at 0001 Update the default manifest

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

fatal: cannot create default in manifest
---------------------------

Is there any known workaround that we can use to switch between manifest 
branches via repo?

Thanks in advance

Original comment by jla...@gmail.com on 4 Oct 2010 at 6:20

GoogleCodeExporter commented 9 years ago
One work around is to delete the "default" branch before switching branches / 
advancing to the next tag. I've implemented this in a repo plugin for Jenkins 
but this workaround is not ideal and is fragile to changes in repo 
implementation.
https://github.com/tgover1/repo-plugin

Original comment by timgo...@gmail.com on 13 Dec 2011 at 12:43

GoogleCodeExporter commented 9 years ago
I pushed a patch proposal to the review server here : 
https://gerrit-review.googlesource.com/35900

It basically implements the solution from comment #3 directly into repo

Original comment by Florian....@gmail.com on 7 Jun 2012 at 3:24

GoogleCodeExporter commented 9 years ago
Fixed in repo 1.9.4

Original comment by sop@google.com on 13 Jun 2012 at 5:01

GoogleCodeExporter commented 9 years ago
Still pretty busted  actually:

Take a look at the results of running:

for x in master release-R20-2268.B master release-R20-2268.B{,} \
 master{,,}; do
  repo init -u https://git.chromium.org/chromiumos/manifest.git -b $x;
  git config -f .repo/manifests/.git/config --get-regexp  \
   'branch\.default\..*'
  git --git-dir .repo/manifests/.git symbolic-ref HEAD;
  echo echo
done

Specifically, track the remote/merge settings; they toggle, sometimes there, 
sometimes not across re-inits; this breaks the git configuration itself, and 
there are cases I've seen where there is *no* merge/origin output (and it's 
left itself on detached HEAD); haven't ran down the cause yet.

This is still broken.

Original comment by ferringb on 20 Jun 2012 at 12:03

GoogleCodeExporter commented 9 years ago
Our group in Samsung is using Repo tool to manage some of our projects, and 
some projects are used as a mirror from other upstream sources.

We normally follow this process when using 'repo init -u URL -b branch' for our 
project.

We saw one of your changes (see below) that might be having some different 
behaviours than what's working for us in the past, but no longer working.  We 
are trying to see the actual reason behind this change and want to know what we 
should do going forward.

This is our process:

We have a mirror project that's mirroring with an upstream project, hence, we 
have a "local" branch of the manifest, and a "master" branch of the manifest. 
Our local branch of the manifest is pointing to your local mirror Gerrit server.

We normally use this workflow:

1) repo init -u ssh://our_local_mirror/projects/ABC -b local
2) repo sync
The manifest file we wanted to use should be from the branch "local".
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <notice>
    Your sources have been sync'd successfully.
  </notice>
  <remote fetch="ssh://192.168.1.52:29418/external/projects/ABC/"
          name="local_mirror"
          review="http://192.168.1.52/"/>
  <default remote="local_mirror" />
3) run some builds

This is what we are seeing:

However, after the "repo sync", we found our manifest.xml is changed back to 
the copy from our upstream (master), it is not using the our "-b local" branch.
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote  name="upstream"
           fetch="http://abc.samsung.com/test"
           review="gerrit.abc.samsung.com/gerrit" />
  <default revision="refs/heads/master"
           remote="upstream" />

We found that now we might be need to use "-d" option for "init", but we had 
tried although nothing has seems to work for us.
Please advise what we should be doing continue forward.

Original comment by s.x...@sta.samsung.com on 21 Jun 2012 at 6:12

GoogleCodeExporter commented 9 years ago
I'm seeing problems with the fix for this issue.

If I run "repo init -u <url> -b <branch> -m <manifest>; repo sync -j5; repo 
init -u <url> -b <branch> -m <manifest>; repo sync -j5" I get the following 
error on the second sync:
username@machine:~/Workspace/mydroid$ repo sync -j5
.repo/manifests/: leaving default; does not track upstream
Traceback (most recent call last):
  File "/home/username/Workspace/mydroid/.repo/repo/main.py", line 385, in <module>
    _Main(sys.argv[1:])
  File "/home/username/Workspace/mydroid/.repo/repo/main.py", line 365, in _Main
    result = repo._Run(argv) or 0
  File "/home/username/Workspace/mydroid/.repo/repo/main.py", line 137, in _Run
    result = cmd.Execute(copts, cargs)
  File "/home/username/Workspace/mydroid/.repo/repo/subcmds/sync.py", line 431, in Execute
    all = self.GetProjects(args, missing_ok=True)
  File "/home/username/Workspace/mydroid/.repo/repo/command.py", line 66, in GetProjects
    all = self.manifest.projects
  File "/home/username/Workspace/mydroid/.repo/repo/manifest_xml.py", line 235, in projects
    self._Load()
  File "/home/username/Workspace/mydroid/.repo/repo/manifest_xml.py", line 287, in _Load
    self.manifestProject.worktree))
  File "/home/username/Workspace/mydroid/.repo/repo/manifest_xml.py", line 302, in _ParseManifestXml
    root = xml.dom.minidom.parse(path)
  File "/usr/lib/python2.6/xml/dom/minidom.py", line 1918, in parse
    return expatbuilder.parse(file)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 922, in parse
    fp = open(file, 'rb')
IOError: [Errno 2] No such file or directory: 
'/home/username/Workspace/mydroid/.repo/manifest.xml'

When I roll back to a version of repo prior to the below commit, I do not see 
this error.

commit 5d016502ebc68bc054d85c98c6cdb51e0b63a1f5
Author: Florian Vallee <florian.vallee@gmail.com>
Date:   Thu Jun 7 17:19:26 2012 +0200

    Fix switching manifest branches using repo init -b

    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

Original comment by ma...@bornski.com on 29 Jun 2012 at 9:00