From 9d1bc83920ea8bed72e6c35b3c7cbaed81324b23 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 12 Jan 2012 15:25:57 +0200 Subject: [PATCH] gbp-pull: similar force update strategy for all branches 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 --- gbp/scripts/pull.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gbp/scripts/pull.py b/gbp/scripts/pull.py index 9027d900..ca467acb 100755 --- a/gbp/scripts/pull.py +++ b/gbp/scripts/pull.py @@ -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 @@ -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 @@ -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: