Makistos
12/28/2015 - 2:11 PM

Find which Git commit a patch can be applied to. Patch file is given as the parameter to this script. Script stops when it finds the commit

Find which Git commit a patch can be applied to. Patch file is given as the parameter to this script. Script stops when it finds the commit that matches. #git #patch #git-apply #bash

#!/bin/bash

for commit in `git rev-list --remotes --all --walk-reflogs` 
do 
	git checkout $commit > /dev/null 2>&1
	echo `git log -1 --oneline`

	err=`git apply --check $1 2>&1`
	#echo $err
	if [[ $err != error* ]]; then 
		break; 
	fi 
done