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 CURRENT_BRANCH_FILE=${CWD}/.current_branch.txt
14 echo "Restore to original git branch."
15 test -f "$CURRENT_BRANCH_FILE" && CURRENT_BRANCH="`cat $CURRENT_BRANCH_FILE`"
16 git checkout ${CURRENT_BRANCH}
17 git branch -D ${PATCH_BRANCH}
18 rm -f $CURRENT_BRANCH_FILE
22 # If --cancel option is given, just reset git and exit.
23 test "$1" == "--cancel" && reset_branch
25 # Remember current branch name to a file
26 echo "${CURRENT_BRANCH}" > $CURRENT_BRANCH_FILE
28 # Make sure if current git is clear.
29 #test -n "`git status -s`" && echo "ERROR: Current git is not clean. Type 'git status' and clean your git up first." && exit 1
32 #git reset --hard HEAD
34 # Create a temporary branch
35 git branch ${PATCH_BRANCH} || reset_branch
36 git checkout ${PATCH_BRANCH} || reset_branch
38 # Apply existing patches into libs/
40 #for patch in `find ${PATCH_DIR} -name '*.patch' -type f`; do
41 # patch -p0 < ${patch} || reset_branch
43 git am $PATCH_DIR/*.patch
45 # Make a temporary commit on $PATCH_BRANCH
46 #git add -f -u . || reset_branch
47 #git commit -m 'Temporary commit applying existing patches' || reset_branch
52 echo "Set up for patch is done. Current temporary git branch name is '${PATCH_BRANCH}', and a temporary commit is created. (This commit and branch will be removed.)"
53 echo "Go change your source, add&commit into git, and run create-patch.sh to make your commit to a patch file in $PATCH_DIR."