Skip to content

Commit e6b33cc

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 <[email protected]>
1 parent 99b3811 commit e6b33cc

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

@@ -184,7 +191,7 @@ def main(argv):
184191
repo.fetch(rem_repo, depth=options.depth)
185192
repo.fetch(rem_repo, depth=options.depth, tags=True)
186193
for branch in branches:
187-
if not fast_forward_branch(rem_repo, branch, repo, options):
194+
if not update_branch(rem_repo, branch, repo, options):
188195
retval = 2
189196

190197
if options.redo_pq:

0 commit comments

Comments
 (0)