Skip to content

Commit d5abdd2

Browse files
committed
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 <markus.lehtonen@linux.intel.com>
1 parent a656995 commit d5abdd2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

gbp/scripts/pull.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import gbp.log
3232

3333

34-
def fast_forward_branch(rem_repo, branch, repo, options):
34+
def update_branch(rem_repo, branch, repo, options):
3535
"""
3636
update branch to its remote branch, fail on non fast forward updates
3737
unless --force is given
@@ -71,10 +71,17 @@ def fast_forward_branch(rem_repo, branch, repo, options):
7171
repo.rev_parse(remote, short=12)))
7272
if repo.branch == branch:
7373
repo.merge(remote)
74-
else:
74+
elif can_fast_forward:
7575
sha1 = repo.rev_parse(remote)
7676
repo.update_ref("refs/heads/%s" % branch, sha1,
7777
msg="gbp: forward %s to %s" % (branch, remote))
78+
else:
79+
# Merge other branch, if it cannot be fast-forwarded
80+
current_branch = repo.branch
81+
repo.set_branch(branch)
82+
repo.merge(remote)
83+
repo.set_branch(current_branch)
84+
7885
return update
7986

8087

@@ -212,7 +219,7 @@ def main(argv):
212219
branches.add(branch)
213220

214221
for branch in branches:
215-
if not fast_forward_branch(rem_repo, branch, repo, options):
222+
if not update_branch(rem_repo, branch, repo, options):
216223
retval = 2
217224

218225
if options.redo_pq:

0 commit comments

Comments
 (0)