#!/bin/bash die() { echo "Error: $@"; exit 1; } SINCE="$1" [[ -z ${SINCE} ]] && die "missing param SINCE" PATCH_DIR="./patches" [[ ! -d ${PATCH_DIR} ]] && install -d ${PATCH_DIR} commit_list=( $(git log --since "${SINCE}" -p --reverse | grep '^commit' | sed 's:commit\ \(.*\):\1:') ) count="${#commit_list[*]}" for (( i=0; i ${PATCH_DIR}/"${i}-${commit_list[$i]}.patch" done