summaryrefslogtreecommitdiff
path: root/builtin/diff-files.c
diff options
context:
space:
mode:
authorLibravatar Joachim Kuebart <joachim.kuebart@gmail.com>2021-05-05 11:56:26 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-05-06 12:51:33 +0900
commit6b79818bfbd39a5d41d15003375a9f382f70ad0e (patch)
tree0250617c517159bfcffa309a4e91d3c08c1af752 /builtin/diff-files.c
parentgit-p4: ensure complex branches are cloned correctly (diff)
downloadtgif-6b79818bfbd39a5d41d15003375a9f382f70ad0e.tar.xz
git-p4: speed up search for branch parent
For every new branch that git-p4 imports, it needs to find the commit where it branched off its parent branch. While p4 doesn't record this information explicitly, the first changelist on a branch is usually an identical copy of the parent branch. The method searchParent() tries to find a commit in the history of the given "parent" branch whose tree exactly matches the initial changelist of the new branch, "target". The code iterates through the parent commits and compares each of them to this initial changelist using diff-tree. Since we already know the tree object name we are looking for, spawning diff-tree for each commit is wasteful. Use the "--format" option of "rev-list" to find out the tree object name of each commit in the history, and find the tree whose name is exactly the same as the tree of the target commit to optimize this. This results in a considerable speed-up, at least on Windows. On one Windows machine with a fairly large repository of about 16000 commits in the parent branch, the current code takes over 7 minutes, while the new code only takes just over 10 seconds for the same changelist: Before: $ time git p4 sync Importing from/into multiple branches Depot paths: //depot Importing revision 31274 (100.0%) Updated branches: b1 real 7m41.458s user 0m0.000s sys 0m0.077s After: $ time git p4 sync Importing from/into multiple branches Depot paths: //depot Importing revision 31274 (100.0%) Updated branches: b1 real 0m10.235s user 0m0.000s sys 0m0.062s Signed-off-by: Joachim Kuebart <joachim.kuebart@gmail.com> Helped-by: Junio C Hamano <gitster@pobox.com> Helped-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/diff-files.c')
0 files changed, 0 insertions, 0 deletions