Created
January 14, 2009 02:58
-
-
Save dsturnbull/46752 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# changed to only work on clean repos | |
# after each revision is tried, if it's still dirty, nuke all untracked files. they represent the situation in which a patch is applied to a file that was added in an unmerged patch | |
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 | |
#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