Skip to content

Instantly share code, notes, and snippets.

@bdrewery
Created March 8, 2011 18:36
Show Gist options
  • Select an option

  • Save bdrewery/860736 to your computer and use it in GitHub Desktop.

Select an option

Save bdrewery/860736 to your computer and use it in GitHub Desktop.
Takes a git repo with expected branches 'base' and 'master' and produces a patch for /usr/src/files/path-REPO
#! /bin/sh
DEST_DIR=$(realpath $1)
for git_repo in *; do
if ! [ -d "${git_repo}/.git" ]; then
continue
fi
PREFIX="./${git_repo//-//}"
pushd $git_repo > /dev/null
echo $git_repo
git checkout master > /dev/null 2>&1
rm -f "${DEST_DIR}/patch-${git_repo}"
touch "${DEST_DIR}/patch-${git_repo}"
echo "Summary:" >> "${DEST_DIR}/patch-${git_repo}"
git diff --stat base..master >> "${DEST_DIR}/patch-${git_repo}"
echo "----" >> "${DEST_DIR}/patch-${git_repo}"
echo "" >> "${DEST_DIR}/patch-${git_repo}"
echo "" >> "${DEST_DIR}/patch-${git_repo}"
echo "Files modified:" >> "${DEST_DIR}/patch-${git_repo}"
git log --stat base..master >> "${DEST_DIR}/patch-${git_repo}"
echo "----" >> "${DEST_DIR}/patch-${git_repo}"
echo "" >> "${DEST_DIR}/patch-${git_repo}"
echo "" >> "${DEST_DIR}/patch-${git_repo}"
git diff --src-prefix="${PREFIX}.orig/" --dst-prefix="${PREFIX}/" base..master >> "${DEST_DIR}/patch-${git_repo}"
popd > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment