commit 3e29484ba9b4ebb67b5ddb7aee0af14a321209db parent 80d038d8dc03de48f67320651b77fa5730c49d39 Author: Nihal Jere <nihal@nihaljere.xyz> Date: Thu, 25 Nov 2021 21:49:32 -0600 use diff-tree instead of ls-tree this is much more efficient, as we only handle changed objects Diffstat:
M | git-submodule-integrate | | | 16 | ++++++---------- |
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/git-submodule-integrate b/git-submodule-integrate @@ -22,17 +22,13 @@ do git -C "$child" cat-file tree "$treehash" | git hash-object -t tree -w --stdin > /dev/null # copy the files and subtrees into the parent - git -C "$child" ls-tree -tr $commit | while read line + git -C "$child" diff-tree --root -t "$commit" | while read line do - mode=$(echo "$line" | cut -d' ' -f1) - type=$(echo "$line" | cut -d' ' -f2) - hash=$(echo "$line" | cut -d' ' -f3 | cut -d' ' -f1) - path=$(echo "$line" | cut -d' ' -f2) - - if ! git cat-file -e "$hash" - then - git -C "$child" cat-file "$type" "$hash" | git hash-object -t "$type" -w --stdin > /dev/null - fi + newhash=$(echo "$line" | cut -d' ' -f4) + type=$(git -C "$child" cat-file -t "$newhash") + [ "$type" = "commit" ] && continue + + git -C "$child" cat-file "$type" "$newhash" | git hash-object -t "$type" -w --stdin > /dev/null done git rm -q -r --cached "$where"