summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-p4.py21
-rwxr-xr-xt/t9801-git-p4-branch.sh2
2 files changed, 12 insertions, 11 deletions
diff --git a/git-p4.py b/git-p4.py
index 09c9e93..d34a194 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -3600,19 +3600,18 @@ class P4Sync(Command, P4UserMap):
return True
def searchParent(self, parent, branch, target):
- parentFound = False
- for blob in read_pipe_lines(["git", "rev-list", "--reverse",
+ targetTree = read_pipe(["git", "rev-parse",
+ "{}^{{tree}}".format(target)]).strip()
+ for line in read_pipe_lines(["git", "rev-list", "--format=%H %T",
"--no-merges", parent]):
- blob = blob.strip()
- if len(read_pipe(["git", "diff-tree", blob, target])) == 0:
- parentFound = True
+ if line.startswith("commit "):
+ continue
+ commit, tree = line.strip().split(" ")
+ if tree == targetTree:
if self.verbose:
- print("Found parent of %s in commit %s" % (branch, blob))
- break
- if parentFound:
- return blob
- else:
- return None
+ print("Found parent of %s in commit %s" % (branch, commit))
+ return commit
+ return None
def importChanges(self, changes, origin_revision=0):
cnt = 1
diff --git a/t/t9801-git-p4-branch.sh b/t/t9801-git-p4-branch.sh
index ff94c3f..50a6f8b 100755
--- a/t/t9801-git-p4-branch.sh
+++ b/t/t9801-git-p4-branch.sh
@@ -294,11 +294,13 @@ test_expect_success 'git p4 clone complex branches' '
test_path_is_file file3 &&
grep update file2 &&
git reset --hard p4/depot/branch4 &&
+ git diff-tree --quiet HEAD &&
test_path_is_file file1 &&
test_path_is_file file2 &&
test_path_is_missing file3 &&
! grep update file2 &&
git reset --hard p4/depot/branch5 &&
+ git diff-tree --quiet HEAD &&
test_path_is_file file1 &&
test_path_is_file file2 &&
test_path_is_file file3 &&