Skip to content

Instantly share code, notes, and snippets.

@toddlipcon
Created April 22, 2014 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddlipcon/11196745 to your computer and use it in GitHub Desktop.
Save toddlipcon/11196745 to your computer and use it in GitHub Desktop.
#!/bin/bash
REMOTE=${GERRIT:-gerrit}
GERRIT_NUMBER=$1
REV_A=$2
REV_B=$3
if ! [[ "$GERRIT_NUMBER" =~ "[0-9]+" ]] || \
! [[ "$REV_A" =~ "[0-9]+" ]] || \
! [[ "$REV_B" =~ "[0-9]+" ]] ; then
echo "usage: $0 <gerrit number> <rev 1> <rev 2>"
echo
echo eg: $0 12345 1 3
echo will show the diff between revision 1 and 3 of gerrit #12345
fi
last_two_digits=$(echo $GERRIT_NUMBER | tail --bytes=3)
set -e
git fetch $REMOTE refs/changes/$last_two_digits/$GERRIT_NUMBER/$REV_A
git format-patch -1 --stdout FETCH_HEAD > /tmp/$GERRIT_NUMBER.$REV_A.patch
git fetch $REMOTE refs/changes/$last_two_digits/$GERRIT_NUMBER/$REV_B
git format-patch -1 --stdout FETCH_HEAD > /tmp/$GERRIT_NUMBER.$REV_B.patch
diff /tmp/$GERRIT_NUMBER.{$REV_A,$REV_B}.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment