Created
July 10, 2019 16:20
-
-
Save paudirac/078e4918b0e5bc0a42e3cebbbd504ccc to your computer and use it in GitHub Desktop.
Inspect git objects of a folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
list_objects () { | |
find .git/objects/ -type f | sed s:.git/objects/:: | sed s:/:: | |
} | |
list_types () { | |
list_objects | xargs -n1 git cat-file -t | |
} | |
count_type () { | |
echo $1: $(list_types | grep $1 | wc -l) | |
} | |
show_detail () { | |
while read obj; do | |
echo -e $(git cat-file -t $obj) "\t$obj" | |
done | |
} | |
list_details () { | |
list_objects | show_detail | |
} | |
cd $1 | |
echo "Git objects of $1" | |
echo $(count_type blob) $(count_type tree) $(count_type commit) | |
echo ---------------------------------------------------------- | |
list_details |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is mainly for demo purposes in tiny repos.