> This may seem like a rookie question, but I think it's valid.
> I'm going to be detailed in the steps for reproducing.
>
>
> My manifest has this line:
>
> <default revision="refs/heads/master"
> remote="origin" />
"master" would've been enough, but "refs/heads/master" is fine too.
> Now, let's say that I have done a repo sync, and I've got a bunch of
> projects.
>
> <project path="projects/firstProject" name="firstProject" />
> <project path="projects/secondProject" name="secondProject" />
>
> I've got my projects, and everything's looking great.
>
> Next, I need to look at a bugfix to a branch that was made months ago
> in firstProject.
> So, I do:
> cd ~/repo_root/projects/firstProject
> git branch -a
> * master
> remotes/origin/HEAD -> origin/master
> remotes/origin/master
> remotes/origin/1.0.0
Hmm. This doesn't quite look like what I'd expected. Have you already
created a topic branch named "master"? What's with the origin/HEAD
symbolic ref? I would've expected a symbolic ref m/master (or whatever
your manifest branch is called) pointing to origin/master.
> Next, I do my checkout to see what's on the 1.0.0 branch.
> git checkout 1.0.0
> Previous HEAD position was b71a548... (some comment)
> Branch 1.0.0 set up to track remote branch 1.0.0 from origin.
> Switched to a new branch '1.0.0'
>
> Wonderful. Everything looks fine to me, so I forget about this awhile.
>
> A few days pass, and then I find out that I need to add a third
> project.
> <project path="projects/thirdProject" name="thirdProject" />
>
> Once that's added, I do a new repo sync.
>
> Uh-oh; something bad happens. Since firstProject was on branch 1.0.0
> instead of master, this message comes up at the end of my sync:
>
> projects/firstProject/: manifest switched refs/heads/1.0.0...refs/
> heads/master
This doesn't make sense. According to the information you've given us,
the manifest has pointed to refs/heads/master all the time.
> projects/firstProject/: discarding 3 commits removed from upstream
>
> Now, oddly, my 1.0.0 local branch is tracking remotes/origin/master,
> not remotes/origin/1.0.0.
> That's totally wrong-- it's like it broke its current tracking to do
> something incorrect.
Checked out topic branches are rebased to the current upstream, so the
behavior you've seen is expected. If you don't want a topic branch to be
rebased, make sure it isn't checked out (run "repo sync -d" to detach
all topic branches).
> This is a little confusing for me.
>
> I kind of want the checked-out branch to track to whatever remote it
> was already specified to.
> So, if firstProject was pointing to 1.0.0, and secondbranch was
> pointing to master, both should "git fetch" and "git rebase remotes/
> origin/(branch_i_am_on)"
Well, that's just not how Repo works. It seems you're looking at Repo's
topic branches as long-lived branches where you make various (in this
case) maintenance bug fixes for a period of maybe months, and with that
view I agree that what you want would've made sense. However, the
intention is that topic branches are short-lived branches for specific
corrections that are to be uploaded to just about any branch. Hence,
1.0.0 doesn't really make sense as a topic branch name, but
fix-overflow-bug does.
> So, the questions I have are:
> 1) Am I crazy, or is there something that I can put in the manifest to
> track branches to their branches respectively, so this doesn't happen?
Nope.
> 2) Is there a way to not specify a default revision in the manifest,
> and still have it function without python errors?
Why would you want to do that? Each project must be bound to a revision.
> 3) I guess if 2 isn't possible, I could maybe have it tie to a default
> tag across the board-- that's something that won't track at all; can a
> tag be done as the default revision?
Sure, just put refs/tags/nameoftag in the revision field. Note that
"repo upload" won't work if you do this (since you can't upload changes
to a tag or a SHA-1).
--
Magnus Bäck Opinions are my own and do not necessarily
SW Configuration Manager represent the ones of my employer, etc.
Sony Ericsson
> For the git branch -a, you're right. I do think it's fishy, so I'm
> going to do a fresh clone, and share what I have:
>
> I'm doing this:
> ./repo init -m manifest.xml -u ssh://<username>@<gerrit_server>:29418/manifest.git
You're working too hard. Use an insteadOf block in your ~/.gitconfig or
a host alias in your ~/.ssh/config to avoid having to type username and
port every time. Put Repo in your $PATH. And why call the manifest
manifest.xml instead of default.xml, forcing users to use the -m option
all the time?
> ./repo sync
> ./repo forall -c "git branch --track master remotes/origin/master"
> ./repo forall -c "git checkout master"
The latter two commands can be replaced by "repo start master", given
that your manifest points to the master branch on all gits.
> Then, I run this:
> cd ~/repo_root/projects/firstProject
> git branch -a
>
> Here's what I see:
> * master
> remotes/m/master -> origin/master
> remotes/origin/1.0.0
> remotes/origin/1.0.1
>
> So, that's good.
Yup.
> It's at this point that I need to specify that as you guessed it, I am
> adapting repo/git to meet the needs of my current employer. I came
> from an android/git background, and understand that the Google model
> for Android projects has certain recommendations for best practices.
> However, in some companies/organizations, the shoe doesn't fit on all
> feet the same way.
While Repo was designed for use with Android, I don't think there's
anything that makes it inherently unsuited for other ways of working.
> The methodology when I came into the picture at this organization was
> to have long-lasting branches that are forks in our code. Most people
> will be on master for the majority of their work, but we do maintain
> "maintenance branches" that may need to be updated with bugfixes on
> occasion. These branches could last for up to 6 months. Now, if I
> remember right, android work usually has a different manifest for each
> code fork-- there's a manifest for IceCreamSandwich, and one for
> Honeycomb. For our needs, it seems to make sense to just use one
> manifest, but it sounds like we'll hit the weird rebase behavior in
> the repo tool when we do that.
Repo uses the manifest to decide which branch to track and where to
upload changes. If you diverge from this you should be prepared for
discovering all sorts of nuisances. You might be able to fix some of
them, but for the rest the tool will just appear awkward.
It's not unusual to have longlived branches, and the evidence you've
presented so far doesn't indicate that you have other needs than Google
or other users of Gerrit. You're not special, you're just different.
You have explained *what* you want to change in Repo and you have
some thoughts of *how*, but the *why* still eludes me. What special
way of working needs to be supported, and what advantages would it
have? Right now it -- honestly -- sounds like it's a feature to support
change-reluctant organizations who got on the wrong track from the
beginning and want to avoid the slight mindset change of actually using
the manifest for what it's meant to be used for.
On the other hand, tools should generally be flexible enough to support
more than one way of working, although I think the different ways should
be sufficiently different and unique to have their own strengths and
weaknesses.
[...]
> So, yeah, our implementation of process doesn't seem to match the
> tool.
> The 2 options here are-- modify the tool, or get the organization
> to change.
> The easier method seems to be to modify repo for our case.
If it's possible to do in a clean way so that you get upstream
acceptance then it might be worth it for you, but beware if you
need to fork Repo itself. The cost for that would be high.
> Based on this, I'm thinking to make a local patch to repo.
> I'm thinking of making a change to the manifest that repo could
> interpret.
>
> One idea is:
>
> <default revision="MYLOCALBRANCH"
> remote="origin" />
>
> and the other is:
>
> <default revision="refs/heads/master" rebaseBranchToManifest="no"
> remote="origin" />
>
>
> The thought would be to tweak repo such that if there's some special
> wildcard in there, "MYLOCALBRANCH", or a special flag to tell it not
> to rebase everything to the manifest that's not checked out, it'll
> rebase to the current branch to its current remote that matches that
> branch.
>
> I'll think on this more; there may be a less-invasive and more-
> intuitive way to set a flag for this.
It sounds like it should be a user preference rather than a per-manifest
(or per-project) setting.
[...]
> So, I'll do some tweaking and share what I come up with for the repo
> tool.
> If it's not too invasive, I'll submit it back for consideration; I'm
> not sure that android developers would have any use for such a
> feature, but it sounds like this might be a little tweak that could
> make repo more globally usable by other users that have different
> branching strategies.
I'm sorry, but it worries me greatly that you think this has anything
to do with branching strategies. You haven't said anything that would
suggest that it's your branching strategy that's requiring this change
in Repo.
Uh-oh; something bad happens. Since firstProject was on branch 1.0.0
instead of master, this message comes up at the end of my sync:
projects/firstProject/: manifest switched refs/heads/1.0.0...refs/
heads/master
projects/firstProject/: discarding 3 commits removed from upstream
> What if you have multiple people working on that branch?
Isn't this thread about local branches, which Repo calls topic branches?
You never have more than one user working on them.