When choosing the branch to submit a changeset against, and
against which to rebase a changeset if it is being rebased, a new
gerrit.track configuration item and corresponding --track command
line option indicate to use the upstream branch being tracked as the
source of branch information, in preference to configuration. When
downloading a changeset, always set it up to track the matching
remote branch to make --track work for downloaded changesets.
If a branch name is provided explicitly on the command line, it
overrides the tracked branch.
Rationale:
Workflows with multiple active branches are common. For example,
there may be one development branch (master) and multiple branches
representing prior releases to which bug fixes are still being
made. Then a common workflow is to fix bugs in the earliest
affected branch still maintained and merge forward or cherry-pick
to master. The commits being made to the earlier released branches
should not be rebased against master.
A typical usage pattern in this workflow is:
git checkout -b my-feature origin/master
... implement feature ...
git review -f
git checkout -b my-bug-fix origin/maintenancebranch
... implement bug fix ...
git review -f maintenancebranch
git checkout -b my-bug-fix-merge origin/master
git merge maintenancebranch / git cherry-pick -x ... / git review -x ...
git review -f
The developer, who is usually implementing features and therefore
used to working against master, may accidentally forget to name
the release branch when running git review for the bug fix to the
release branch. Mananging .gitreview files across branches and
repositories scales poorly with larger numbers of repositories
and branches and can be vulnerable to missed bad merges altering
configuration to point at wrong branches.
This change rebases changesets against the tracked remote and branch,
or if no branch is tracked, against the previously-specified branch,
instead of against <defaultremote>/master, only if gerrit.track has
been set to true. With this change, the developer can safely omit
to specify the branch name when committing changes to non-default
branches such as "maintenancebranch" in the example.
When downloading a changeset, it will always be set up to track the
matching remote branch. That way, whether or not the gerrit.track
configuration item is set when the changeset is downloaded, the right
branch will be chosen when it is submitted if gerrit.track is set
after the changeset is downloaded, or if the --track command line
option is specified.
Closes-Bug: #883176
Story: #883176
Story: #2000176
Change-Id: I25f22b9e3cda38598681d720a2f2ac534baec5a6