@@ -21,7 +21,57 @@ contCommit() {
2121 echo " Enter commit to display:"
2222 read cname
2323 [ " ${cname} " = " " ] && waitonexit && return
24- 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+ echo " Enter custom commit to explore or press enter to take branch head!"
57+ read ccommit
58+ [ " $ccommit " != " " ] && commit=$ccommit ;
59+ importantLog " commit: $commit "
60+ # Step 3: Get the tree object from the commit object
61+ tree=$( git cat-file -p " $commit " | awk ' /^tree/ {print $2}' )
62+ importantLog " tree: $tree "
63+ # Step 4: Get all tree and blob objects from the tree object
64+ blueLog " blobs in tree:"
65+ git ls-tree -r " $tree "
66+ blueLog " trees in tree:"
67+ git ls-tree -d " $tree "
68+ }
69+
70+ contObject () {
71+ echo " Enter hash:"
72+ read chash
73+ [ " $chash " = " " ] && waitonexit && return
74+ executeCommand " git cat-file -p $chash "
2575}
2676
2777setActual
@@ -32,7 +82,12 @@ menuItem b "Current HEAD pointer" "git symbolic-ref HEAD"
3282menuItem c " Inspect current tree object" " git cat-file -p ${actual} ^{tree}"
3383menuItem d " Inspect current commit object" " git cat-file -p ${actual} ^{commit}"
3484menuItem e " Show contents of commit object" contCommit
35- menuItem e " All branches" allBranches
36- menuItem f " All tags" allTags
85+ menuItem f " All branches" allBranches
86+ menuItem g " All tags" allTags
87+ menuItem h " The actuial list of blobs" " git ls-tree -r HEAD"
88+ menuItem i " The actuial list of trees" " git ls-tree HEAD | grep tree"
89+ menuItem j " All GIT objects" showAllGitObjects
90+ menuItem k " Current objects HEAD>BRANCH>COMMIT>OBJECTS" currentObjects
91+ menuItem l " Show contents of object" contObject
3792startMenu " setActual"
3893noterminate
0 commit comments