Skip to content

Commit d7e3868

Browse files
committed
Fix git-p4 rebase to detect the correct upstream branch instead of unconditionally
always rebasing on top of remotes/p4/master Signed-off-by: Simon Hausmann <[email protected]>
1 parent 27d2d81 commit d7e3868

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

contrib/fast-import/git-p4

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,9 +1361,17 @@ class P4Rebase(Command):
13611361
def run(self, args):
13621362
sync = P4Sync()
13631363
sync.run([])
1364-
print "Rebasing the current branch"
1364+
1365+
[upstream, settings] = findUpstreamBranchPoint()
1366+
if len(upstream) == 0:
1367+
die("Cannot find upstream branchpoint for rebase")
1368+
1369+
# the branchpoint may be p4/foo~3, so strip off the parent
1370+
upstream = re.sub("~[0-9]+$", "", upstream)
1371+
1372+
print "Rebasing the current branch onto %s" % upstream
13651373
oldHead = read_pipe("git rev-parse HEAD").strip()
1366-
system("git rebase p4")
1374+
system("git rebase %s" % upstream)
13671375
system("git diff-tree --stat --summary -M %s HEAD" % oldHead)
13681376
return True
13691377

0 commit comments

Comments
 (0)