Skip to content

Instantly share code, notes, and snippets.

@jbranchaud
Created November 29, 2011 22:44
Show Gist options
  • Save jbranchaud/1406952 to your computer and use it in GitHub Desktop.
Save jbranchaud/1406952 to your computer and use it in GitHub Desktop.
Find the revision number previous to the given one for the given file
#!/bin/bash
# Given a filename and a revision number, find the revision number previous to this one.
fname=$1
curr=$2
prev=""
for revnum in `svn log -q $fname | awk '/^r/ {print $1}' | sed -e 's/r//' | sort -n`
do
if [ "$curr" == "$revnum" ]
then
break
else
prev=$revnum
fi
done
echo $prev
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment