Created
September 6, 2014 05:27
-
-
Save uasi/9ec5d2d7fdea7a49567e to your computer and use it in GitHub Desktop.
git-patchbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# git-patchbox | |
# | |
# Saves a series of patches from the given revision to HEAD as | |
# <toplevel>/,patchbox/<name>.mbox and then reset to the revision. | |
# | |
if [ "x$1" = "x" -o "x$2" = "x" ]; then | |
echo "usage: git-patchbox <revision> <mbox name>" | |
exit 1 | |
fi | |
revision=$1 | |
mbox_name=${2}.mbox | |
if [ "${revision#*..}" != "$revision" ]; then | |
echo "fatal: revision must not be a range" | |
exit 1 | |
fi | |
git_dir=`git rev-parse --git-dir` | |
[ -d "$git_dir" ] || exit 1 | |
patchbox=`git rev-parse --show-toplevel`/,patchbox | |
if [ -e "$patchbox/$mbox_name" ]; then | |
echo "fatal: mbox already exists" | |
exit 1 | |
fi | |
mkdir -p "$patchbox" | |
set -e | |
set -x | |
git format-patch --stdout "$revision" > "$patchbox/$mbox_name" | |
git reset --hard "$revision" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.gitignore に
,*/
書いとくと便利