Skip to content

Instantly share code, notes, and snippets.

@moonray
Created October 29, 2010 18:29
Show Gist options
  • Save moonray/654079 to your computer and use it in GitHub Desktop.
Save moonray/654079 to your computer and use it in GitHub Desktop.
p and d functions to use in .bash_profile
function p {
wget -O tmp.patch $1; patch -p0 < tmp.patch; d tmp.patch;
}
function d {
# cvs diff -upNF^f . > $1.patch
git diff --no-prefix HEAD . > $1.patch;
# Clean up to avoid possible issues.
rm -f $1.tmp.patch
# Find every instance of the dpm()
count=`diff_word_count "dpm(" $1.patch`
if [ $count -gt 0 ]; then
echo WARNING! Found $count instances of dpm\(\)! >> $1.tmp.patch
fi
# Find every instance of the dsm()
count=`diff_word_count "dsm(" $1.patch`
if [ $count -gt 0 ]; then
echo WARNING! Found $count instances of dsm\(\)! >> $1.tmp.patch
fi
# Find every instance of the debug()
count=`diff_word_count "debug(" $1.patch`
if [ $count -gt 0 ]; then
echo WARNING! Found $count instances of debug\(\)! >> $1.tmp.patch
fi
# Add contents of $1.patch below our warnings.
count=`cat $1.tmp.patch | wc -l`
if [ $count -gt 0 ]; then
echo ------------------------------------------------------------------------------ >> $1.tmp.patch
fi
cat $1.patch >> $1.tmp.patch
# Dump everything back into $1.patch and delete our temporary file.
cat $1.tmp.patch > $1.patch
rm -f $1.tmp.patch
bbedit ./$1.patch;
}
function diff_word_count {
cat $2 | grep $1 | wc -l
}
@chrisbryant
Copy link

Maybe we should add something like this into git precommit hooks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment