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 "Reset git to original git branch..."
15 test -f "$CURRENT_BRANCH_FILE" && CURRENT_BRANCH="`cat $CURRENT_BRANCH_FILE`"
16 git checkout ${CURRENT_BRANCH}
17 test -e ".git/rebase-apply" && git am --abort
18 git branch -D ${PATCH_BRANCH}
19 rm -f $CURRENT_BRANCH_FILE
23 # If --cancel option is given, just reset git and exit.
24 test "$1" == "--cancel" && reset_branch
26 # If current branch file is already exist, reset and exit.
27 test -f "$CURRENT_BRANCH_FILE" && reset_branch
29 # Remember current branch name to a file
30 echo "${CURRENT_BRANCH}" > $CURRENT_BRANCH_FILE
32 # Make sure if current git is clear.
33 #test -n "`git status -s`" && echo "ERROR: Current git is not clean. Type 'git status' and clean your git up first." && exit 1
36 #git reset --hard HEAD
38 # Create a temporary branch
39 git branch ${PATCH_BRANCH} || reset_branch
40 git checkout ${PATCH_BRANCH} || reset_branch
42 # Apply existing patches into libs/
44 #for patch in `find ${PATCH_DIR} -name '*.patch' -type f`; do
45 # patch -p0 < ${patch} || reset_branch
47 git am $PATCH_DIR/*.patch
49 # Make a temporary commit on $PATCH_BRANCH
50 #git add -f -u . || reset_branch
51 #git commit -m 'Temporary commit applying existing patches' || reset_branch
56 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.)"
57 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."