6 PATCH_DIR=$LIB_DIR/patch
8 CURRENT_BRANCH="`git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`"
9 PATCH_BRANCH="temp-patch"
10 ORIG_BRANCH_FILE="${CWD}/.current_branch.txt"
11 ORIG_BRANCH="`cat $ORIG_BRANCH_FILE 2>/dev/null`"
15 if test -n "$1"; then ret=$1; else ret=1; fi;
16 echo "Restore to original git branch."
17 git checkout ${ORIG_BRANCH}
18 git branch -D ${PATCH_BRANCH}
19 rm -f $ORIG_BRANCH_FILE
23 # Make sure if current branch is PATCH_BRANCH
24 test ! -f "$ORIG_BRANCH_FILE" && echo "ERROR: Original branch file ($ORIG_BRANCH_FILE) is not found!" && exit 1
25 test "${CURRENT_BRANCH}" != "$PATCH_BRANCH" && echo "ERROR: Current branch is not '$PATCH_BRANCH'." && exit 1
27 # Extract patch files from latest commit
28 git format-patch -N --output-directory ${PATCH_DIR} ${ORIG_BRANCH}
30 # Reset branch to original branch
35 echo "Creating your patch is done. Your patch is in ${PATCH_DIR}. Check your patch and add to git."