subtree: performance improvement for finding unexpected parent commits
authorRoger Strain <rstrain@swri.org>
Fri, 12 Oct 2018 13:52:18 +0000 (08:52 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Oct 2018 14:28:32 +0000 (23:28 +0900)
After testing a previous patch at larger scale, a performance issue was
detected when using git show to locate parent revisions, with a single
run of the git show command taking 2 seconds or longer in a complex repo.
When the command is required tens or hundreds of times in a run of the
script, the additional wait time is unaccepatable. Replacing the command
with git rev-parse resulted in significantly increased performance, with
the command in question returning instantly.

Signed-off-by: Roger Strain <rstrain@swri.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree/git-subtree.sh
index 1c157dbd95f49a2514eb311cd549dbbab6f8b4b3..147201dc6c5786c9cfedbbbff0df0b1dced171db 100755 (executable)
@@ -633,7 +633,7 @@ process_split_commit () {
        else
                # processing commit without normal parent information;
                # fetch from repo
-               parents=$(git show -s --pretty=%P "$rev")
+               parents=$(git rev-parse "$rev^@")
                extracount=$(($extracount + 1))
        fi