Created
October 5, 2009 05:11
-
-
Save spazm/201901 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/bash | |
# | |
# By Andrew Grangaard ( http://www.lowlevelmanager.com ) | |
# inspired by | |
# svnvimdiff: | |
# Copyright 2007 by Geoff Buchan | |
# http://www.vim.org/scripts/script.php?script_id=1797 | |
# which was | |
# Based on the script cvsvimdiff, written by | |
# Stefano Zacchiroli <[email protected]> | |
# Enrico Tassi <[email protected]> | |
# | |
# This is free software, you can redistribute it and/or modify it under the | |
# terms of the GNU General Public License version 2 as published by the Free | |
# Software Foundation. | |
if [[ $# < 0 || $1 == "--help" || $1 == "-h" ]] ; then | |
echo "svnvimdiff - script to show svn diff in vimdiff format" | |
echo "" | |
echo "svnvimdiff [options] file" | |
echo "" | |
echo "Option:" | |
echo "Other options are passed to svn diff" | |
echo "" | |
echo "If file is omitted it will cycle through all changed files in" | |
echo "the current directory." | |
exit 1 | |
fi | |
svnvimdiff="svn diff --diff-cmd vimdiff-svn-wrapper" | |
# Assume the last argument is the filename. | |
# Save everything to pass to svn diff | |
if (( $# > 0 )) ; then | |
shift_args=$(($# - 1)) | |
else | |
shift_args=$# | |
fi | |
args=$* | |
shift $shift_args | |
files="$1" | |
if [ -z $files ] || ! [ -f $files ] ; then | |
# No file given, so loop over all files svn st says have changed | |
files=$(svn st 2> /dev/null | grep -e "^[MU]" | cut -c 3-) | |
echo "modified svn tracked files:\n$files"; | |
for f in $files; do | |
if ! [ -f $f ]; then break; fi | |
echo "vimdiff $f" | |
$svnvimdiff $f | |
#give a second to catch this sleeping and kill it, in between files if necessary. | |
sleep 1; | |
done | |
else | |
# file given, so just work with that one | |
$svnvimdiff $files | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment