|
31 | 31 | import gbp.log
|
32 | 32 |
|
33 | 33 |
|
34 |
| -def fast_forward_branch(rem_repo, branch, repo, options): |
| 34 | +def update_branch(rem_repo, branch, repo, options): |
35 | 35 | """
|
36 | 36 | update branch to its remote branch, fail on non fast forward updates
|
37 | 37 | unless --force is given
|
@@ -71,10 +71,17 @@ def fast_forward_branch(rem_repo, branch, repo, options):
|
71 | 71 | repo.rev_parse(remote, short=12)))
|
72 | 72 | if repo.branch == branch:
|
73 | 73 | repo.merge(remote)
|
74 |
| - else: |
| 74 | + elif can_fast_forward: |
75 | 75 | sha1 = repo.rev_parse(remote)
|
76 | 76 | repo.update_ref("refs/heads/%s" % branch, sha1,
|
77 | 77 | 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 | + |
78 | 85 | return update
|
79 | 86 |
|
80 | 87 |
|
@@ -184,7 +191,7 @@ def main(argv):
|
184 | 191 | repo.fetch(rem_repo, depth=options.depth)
|
185 | 192 | repo.fetch(rem_repo, depth=options.depth, tags=True)
|
186 | 193 | 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): |
188 | 195 | retval = 2
|
189 | 196 |
|
190 | 197 | if options.redo_pq:
|
|
0 commit comments