Skip to content

Instantly share code, notes, and snippets.

@tcooper
Created December 18, 2013 20:28
Show Gist options
  • Save tcooper/8029372 to your computer and use it in GitHub Desktop.
Save tcooper/8029372 to your computer and use it in GitHub Desktop.
Generates a 'binary_hashes' entry for supplied object(s)
#!/bin/bash
# Generates a 'binary_hashes' entry for supplied object(s)
for OBJ in "$@"
do
OBJ_BASENAME=`basename ${OBJ}`
OBJ_DIRNAME=`dirname ${OBJ}`
if [ -f ${OBJ} ]; then
OBJ_SIZE=`ls -l $OBJ | awk '{print $5}'`
OBJ_HASH=`git hash-object -t blob $OBJ`
OBJ_NAME=${OBJ}
printf "%15d %40s %s\n" $OBJ_SIZE $OBJ_HASH $OBJ_NAME
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment