Skip to content

Commit

Permalink
gbp-pull: similar force update strategy for all branches
Browse files Browse the repository at this point in the history
When using --force, treat non-checked-out branches similarly to the
current branch. That is, do git merge, instead of just setting the ref.

Also, renames fast_forward_branch() to update_branch() to better match
the functionality.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
  • Loading branch information
marquiz committed Sep 14, 2018
1 parent 1e31e67 commit d383c44
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions gbp/scripts/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import gbp.log


def fast_forward_branch(rem_repo, branch, repo, options):
def update_branch(rem_repo, branch, repo, options):
"""
update branch to its remote branch, fail on non fast forward updates
unless --force is given
Expand Down Expand Up @@ -71,10 +71,17 @@ def fast_forward_branch(rem_repo, branch, repo, options):
repo.rev_parse(remote, short=12)))
if repo.branch == branch:
repo.merge(remote)
else:
elif can_fast_forward:
sha1 = repo.rev_parse(remote)
repo.update_ref("refs/heads/%s" % branch, sha1,
msg="gbp: forward %s to %s" % (branch, remote))
else:
# Merge other branch, if it cannot be fast-forwarded
current_branch = repo.branch
repo.set_branch(branch)
repo.merge(remote)
repo.set_branch(current_branch)

return update


Expand Down Expand Up @@ -212,7 +219,7 @@ def main(argv):
branches.add(branch)

for branch in branches:
if not fast_forward_branch(rem_repo, branch, repo, options):
if not update_branch(rem_repo, branch, repo, options):
retval = 2

if options.redo_pq:
Expand Down

0 comments on commit d383c44

Please sign in to comment.