@@ -21,7 +21,54 @@ contCommit() {
2121 echo " Enter commit to display:"
2222 read cname
2323 [ " ${cname} " = " " ] && waitonexit && return
24- executCommand " git cat-file -p $cname "
24+ executeCommand " git cat-file -p $cname "
25+ }
26+
27+ showAllGitObjects () {
28+ # Iterate over each hash
29+ while read -r hash filename; do
30+ # Get the type of object for the hash
31+ obj_type=$( git cat-file -t " $hash " )
32+
33+ if [ " $obj_type " = " commit" ]; then
34+ commit_date=$( git cat-file -p $hash | awk ' /^author / {print $5}' | xargs date -r)
35+ else
36+ commit_date=" "
37+ fi
38+
39+ # Output the hash and its corresponding object type
40+ echo " $hash : $obj_type $filename $commit_date "
41+ done < <( {
42+ git rev-list --objects --all
43+ git rev-list --objects -g --no-walk --all
44+ git rev-list --objects --no-walk \
45+ $( git fsck --unreachable |
46+ grep ' ^unreachable commit' |
47+ cut -d' ' -f3)
48+ } | sort | uniq | sort -k2)
49+ }
50+
51+ currentObjects () {
52+ branch=$( git rev-parse --abbrev-ref HEAD)
53+ importantLog " branch: $branch "
54+ # Step 2: Get the commit object from the branch
55+ commit=$( git rev-parse " $branch " )
56+ importantLog " head commit: $commit "
57+ # Step 3: Get the tree object from the commit object
58+ tree=$( git cat-file -p " $commit " | awk ' /^tree/ {print $2}' )
59+ importantLog " tree: $tree "
60+ # Step 4: Get all tree and blob objects from the tree object
61+ blueLog " blobs in tree:"
62+ git ls-tree -r " $tree "
63+ blueLog " trees in tree:"
64+ git ls-tree -d " $tree "
65+ }
66+
67+ contObject () {
68+ echo " Enter hash:"
69+ read chash
70+ [ " $chash " = " " ] && waitonexit && return
71+ executeCommand " git cat-file -p $chash "
2572}
2673
2774setActual
@@ -34,5 +81,10 @@ menuItem d "Inspect current commit object" "git cat-file -p ${actual}^{commit}"
3481menuItem e " Show contents of commit object" contCommit
3582menuItem f " All branches" allBranches
3683menuItem g " All tags" allTags
84+ menuItem h " The actuial list of blobs" " git ls-tree -r HEAD"
85+ menuItem i " The actuial list of trees" " git ls-tree HEAD | grep tree"
86+ menuItem j " All GIT objects" showAllGitObjects
87+ menuItem k " Current objects HEAD>BRANCH>COMMIT>OBJECTS" currentObjects
88+ menuItem l " Show contents of object" contObject
3789startMenu " setActual"
3890noterminate
0 commit comments