File tree Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change 88# if correct-branch does exist, it merges the commits
99set -e
1010
11- if [ $1 ]
11+ if [ " $1 " ]
1212then
13+ # shellcheck disable=SC2046,SC2143
1314 if [ ! $( echo " $1 " | grep -E " ^[0-9]+$" ) ]
1415 then
1516 echo " $1 is not a number."
1617 echo " Usage: git move-commits <num-commits> <correct-branch>" ;
1718 exit 1;
1819 else
1920 # The count is 0 based, so to move the last 1 commit, we need HEAD~0
20- NUM_COMMITS=$1
21+ NUM_COMMITS=" $1 "
2122 (( NUM_COMMITS-- ))
2223 echo " num commits $NUM_COMMITS "
2324 fi
2425else
2526 echo " Usage: git move-commits <num-commits> <correct-branch>" ;
2627 exit 1;
2728fi
28- if [ -z $2 ]
29+ if [ -z " $2 " ]
2930then
3031 echo " Usage: git move-commits <num-commits> <correct-branch>" ;
3132 exit 1;
3233else
33- BRANCH=$2
34+ BRANCH=" $2 "
3435fi
3536
36- CURRENT_BRANCH=` git branch | grep ' *' | perl -e ' <STDIN> =~ /^..(.+)$/;print $1' `
37+ # shellcheck disable=SC2063
38+ CURRENT_BRANCH=$( git branch | grep ' *' | perl -e ' <STDIN> =~ /^..(.+)$/;print $1' )
3739
3840# If the branch already exists, we have to merge it with the current branch
39- if ! [ -z ` git branch -a | grep $BRANCH ` ]
41+ # shellcheck disable=SC2143,SC2046
42+ if ! [ -z $( git branch -a | grep " $BRANCH " ) ]
4043then
4144 echo " $BRANCH already exists. Switching to it and merging $CURRENT_BRANCH "
42- git checkout $BRANCH
43- git merge $CURRENT_BRANCH
45+ git checkout " $BRANCH "
46+ git merge " $CURRENT_BRANCH "
4447else
4548 echo " Creating $BRANCH "
46- git branch $BRANCH
49+ git branch " $BRANCH "
4750fi
48- git reset --hard $CURRENT_BRANCH ~$NUM_COMMITS
49- git checkout $BRANCH
51+ git reset --hard " $CURRENT_BRANCH ~$NUM_COMMITS "
52+ git checkout " $BRANCH "
You can’t perform that action at this time.
0 commit comments