Created
February 2, 2010 00:47
-
-
Save dsturnbull/292232 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/sh | |
# Simon Howe <[email protected]> | |
# David Turnbull <[email protected]> | |
git cherry -v HEAD $1 | grep ^+ | while read line; do | |
status=$( git status ) | |
if current_git_status=$( echo "$status" | grep 'working directory clean' ); then | |
hash=`git rev-parse --short $( echo "$line" | cut -d' ' -f2 )` | |
description=$( echo "$line" | cut -d' ' -f3- | cut -c 1-64 ) | |
conflict=$( git cherry-pick -n $hash 2> /dev/null | grep 'CONFLICT' ) | |
if [ "$conflict" ]; then | |
num_conflicting_files=$( echo "$status" | grep 'unmerged: ' | wc -l | sed 's/ //g' ) | |
num_conflicts=$( git diff | grep '++=======' | wc -l | sed 's/ //g' ) | |
printf "+ \033[01;31m$hash\033[00m %1d %2d %s\n" "$num_conflicting_files" "$num_conflicts" "$description" | |
else | |
printf "+ \033[01;32m$hash\033[00m $description\n" | |
fi | |
git reset --hard > /dev/null | |
git status | grep "# " | awk '{print $2}' | xargs rm -r 2>/dev/null | |
#else echo "- $hash $description" | |
else | |
echo "dirty!" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment