Skip to content

Instantly share code, notes, and snippets.

View nickshanks's full-sized avatar

Nicholas Shanks nickshanks

View GitHub Profile
@nickshanks
nickshanks / git-closest-tree.sh
Created February 20, 2014 09:15
Prints out a list of hashes from the master branch and their distance from the current HEAD. This is useful for finding the fork point of a tree dump you may have received via email or similar. Relies on the porcelain command diff-tree so expect it to break in future.
#!/bin/bash
HASHES=$(git rev-list master)
HASHES=($HASHES)
for HASH in "${HASHES[@]}"
do
STATS=($(git diff-tree --minimal --shortstat -w HEAD $HASH))
echo "$HASH => ${STATS[0]} files changed, $((${STATS[3]}+${STATS[5]})) lines changed (+${STATS[3]}/-${STATS[5]})"
done
#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode, add the script's path to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset