Skip to content

Commit e289f68

Browse files
committed
Merge branch 'jk/p4-locate-branch-point-optim'
"git p4" learned to find branch points more efficiently. * jk/p4-locate-branch-point-optim: git-p4: speed up search for branch parent git-p4: ensure complex branches are cloned correctly
2 parents eede711 + 6b79818 commit e289f68

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

git-p4.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3600,19 +3600,18 @@ def importNewBranch(self, branch, maxChange):
36003600
return True
36013601

36023602
def searchParent(self, parent, branch, target):
3603-
parentFound = False
3604-
for blob in read_pipe_lines(["git", "rev-list", "--reverse",
3603+
targetTree = read_pipe(["git", "rev-parse",
3604+
"{}^{{tree}}".format(target)]).strip()
3605+
for line in read_pipe_lines(["git", "rev-list", "--format=%H %T",
36053606
"--no-merges", parent]):
3606-
blob = blob.strip()
3607-
if len(read_pipe(["git", "diff-tree", blob, target])) == 0:
3608-
parentFound = True
3607+
if line.startswith("commit "):
3608+
continue
3609+
commit, tree = line.strip().split(" ")
3610+
if tree == targetTree:
36093611
if self.verbose:
3610-
print("Found parent of %s in commit %s" % (branch, blob))
3611-
break
3612-
if parentFound:
3613-
return blob
3614-
else:
3615-
return None
3612+
print("Found parent of %s in commit %s" % (branch, commit))
3613+
return commit
3614+
return None
36163615

36173616
def importChanges(self, changes, origin_revision=0):
36183617
cnt = 1

t/t9801-git-p4-branch.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,13 @@ test_expect_success 'git p4 clone complex branches' '
294294
test_path_is_file file3 &&
295295
grep update file2 &&
296296
git reset --hard p4/depot/branch4 &&
297+
git diff-tree --quiet HEAD &&
297298
test_path_is_file file1 &&
298299
test_path_is_file file2 &&
299300
test_path_is_missing file3 &&
300301
! grep update file2 &&
301302
git reset --hard p4/depot/branch5 &&
303+
git diff-tree --quiet HEAD &&
302304
test_path_is_file file1 &&
303305
test_path_is_file file2 &&
304306
test_path_is_file file3 &&

0 commit comments

Comments
 (0)