Last active
March 23, 2019 02:45
-
-
Save dineshba/655af687f07e15a067ed8c09d1914333 to your computer and use it in GitHub Desktop.
Display what the commit is made of. It will show the tree, blobs and the structure of it.
This file contains 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
# usage show_commit commit-sha | |
# usage show_commit HEAD | |
#!/bin/sh | |
show_tree() { | |
spacing=$2 | |
printf "$spacing showing tree $1 \n" | |
for one in $(git cat-file -p $1 | awk '{printf $2"--"$3 "\n"}'); do | |
printf "$spacing $one \n" | |
done; | |
tree_count=$(git cat-file -p $1 | rg tree | awk '{print $3}' | wc -l) | |
if [ $tree_count -ne 0 ]; then | |
printf "$spacing sub-trees of tree $1 \n\n" | |
printf "$spacing **************** start sub tree section ********** \n" | |
for row in $(git cat-file -p $1 | rg tree | awk '{print $3}'); do | |
show_tree $row "$spacing" | |
done; | |
printf "$spacing **************** end sub tree section ********** \n\n" | |
fi | |
printf "$spacing =================== \n" | |
} | |
printf "showing commit $1\n" | |
for one in $(git cat-file -p $1 | head -n 2| awk '{printf $1"--"$2 "\n"}'); do | |
printf "$one \n" | |
done; | |
printf "=================== \n" | |
tree=$(git cat-file -p $1| head -n 1 | awk '{print $2}') | |
show_tree $tree " " | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment