Skip to content

Instantly share code, notes, and snippets.

@mborgerson
Last active April 2, 2018 18:31
Show Gist options
  • Save mborgerson/df3668ebabfe8f22cd53227755cbf154 to your computer and use it in GitHub Desktop.
Save mborgerson/df3668ebabfe8f22cd53227755cbf154 to your computer and use it in GitHub Desktop.
Find Patchset Base
#!/bin/bash
#
# This script will try to apply a patch set to a range of commits and stop
# once one is successfully identified. Useful for identifying the applicable
# patch base for an old patch set in a rapidly changing repository.
#
TAG_FROM='v2.8.1.1'
TAG_TO='v2.9.0'
PATCHDIR="$PWD/../patches"
for changeset in `git log --pretty=oneline $TAG_FROM..$TAG_TO | cut -f1 -d' '`; do
echo "Testing Changeset: $changeset"
git checkout $changeset
git am $PATCHDIR/*
if [[ $? -eq 0 ]]; then
echo "Found! Rev: $changeset"
break
else
echo "Patch unsuccessful..."
git am --abort
git reset --hard $changeset
git clean -fdxx
fi
echo -e "\n--\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment