In my project there is a directory (i.e. db/updates/) where all updates of DB are stored. Each update is in single file (i.e. update_1.sql, update_2.sql etc). When release is made I need scope of files that where added/updated since last revision (which stored in DB). Now I'm doing it the following way:
# pull changes
git pull origin branch --force
# make patch
git diff $last_revision -- ./db/updates > ./PATCH
# remove all files in directory /db/updates
rm -rf ./db/updates/*
# apply changes
git apply --ignore-whitespace --inaccurate-eof ./PATCH
It works fine, but there are cases when it fails. If there were changes in files between commits B and C in files that where added with commit A the patch will fail with error error: db/updates/update_xxx.sql : No such file or directory
How to ignore missing files? I'd use --diff-filter=A while creating patch, but this will ignore all changes that where commited between needed revision B and C.