@@ -280,11 +280,11 @@ handleParams() {
280280 g_iExitCode=65
281281 error ' This script expects four command-line arguments'
282282 elif [[ " ${g_bShowHelp} " = false ]]; then
283- readonly g_sTargetDirectory=" ${3} "
284- readonly g_sStrategy=" ${4} "
285283
286284 sRootFile=$( readlink -f " ${1} " )
287285 sSplitDirectory=$( readlink -f " ${2} " )
286+ readonly g_sTargetDirectory=$( readlink -f " ${3} " )
287+ readonly g_sStrategy=" ${4} "
288288
289289 if [[ ! -f " ${sRootFile} " ]]; then
290290 g_iExitCode=66
@@ -415,11 +415,13 @@ mergeSplitBranch() {
415415}
416416
417417renameFile () {
418- local sFile=" ${1} "
418+ local sFile
419+
420+ sFile=" ${1} "
419421
420422 if [[ ! -f " ${g_sSourceFilePath} " ]]; then
421423 printStatus " File '${g_sSourceFilePath} ' does not exist. Checking out from '${g_sRootBranch} '"
422- git checkout " ${g_sRootBranch} " -- " ${g_sSourceFilePath} "
424+ git checkout " ${g_sRootBranch} " -- " ${g_sSourceFilePath} " | indent
423425 fi
424426
425427 if [[ ! -d " ${g_sTargetDirectory} " ]]; then
@@ -471,9 +473,10 @@ createSubBranches() {
471473}
472474
473475splitFiles () {
474- local sFile
476+ local sFile sFileName
475477
476478 for sFile in ${g_sSplitDirectory} /* ; do
479+ sFileName=" $( basename ${sFile} ) "
477480 # if [[ "${sFile}" = "${g_sSourceFileName}" ]];then
478481 # printStatus "Skipping source file '${g_sSourceFileName}'"
479482 # else
@@ -483,8 +486,8 @@ splitFiles() {
483486 printDebug " sFileName = ${sFileName} "
484487
485488 checkoutSplitBranch " ${sFile} "
486- renameFile " ${sFile } "
487- commitFileContent " ${sFile } "
489+ renameFile " ${sFileName } "
490+ commitFileContent " ${sFileName } "
488491 # fi
489492 done
490493}
@@ -511,33 +514,35 @@ mergeSplitBranches() {
511514runCleanup () {
512515 local sBranchName sFile
513516
514- read -n1 -p ' Remove all created branches? (y/n) ' sContinue
515- echo " "
517+ if [[ " ${g_sSourceBranch:- } " && " ${g_sSplitDirectory:- } " ]]; then
518+ read -n1 -p ' Remove all created branches? (y/n) ' sContinue
519+ echo " "
516520
517- if [[ " ${sContinue} " = ' y' ]]; then
518- printStatus ' Removing all the split branches that were created'
521+ if [[ " ${sContinue} " = ' y' ]]; then
522+ printStatus ' Removing all the split branches that were created'
523+
524+ git branch -D " ${g_sSourceBranch} " | indent
519525
520- git branch -D " ${g_sSourceBranch} " | indent
526+ for sFile in ${g_sSplitDirectory} /* ; do
527+ sBranchName=" ${g_sSourceBranch} _${sFile} "
521528
522- for sFile in ${g_sSplitDirectory} /* ; do
523- sBranchName=" ${g_sSourceBranch} _${sFile} "
529+ # shellcheck disable=SC2086
530+ if [[ -n " $( git show-ref refs/heads/${sBranchName} ) " ]]; then
531+ # Branch exists
532+ git branch -D " ${sBranchName} " | indent
533+ fi
534+ done
535+ sBranchName=" ${g_sSourceBranch} _${g_sSourceFileName} "
524536
525537 # shellcheck disable=SC2086
526538 if [[ -n " $( git show-ref refs/heads/${sBranchName} ) " ]]; then
527539 # Branch exists
528540 git branch -D " ${sBranchName} " | indent
529541 fi
530- done
531- sBranchName=" ${g_sSourceBranch} _${g_sSourceFileName} "
532542
533- # shellcheck disable=SC2086
534- if [[ -n " $( git show-ref refs/heads/${sBranchName} ) " ]]; then
535- # Branch exists
536- git branch -D " ${sBranchName} " | indent
543+ else
544+ printStatus ' Leaving all branches in place.'
537545 fi
538-
539- else
540- printStatus ' Leaving all branches in place.'
541546 fi
542547
543548 printRuler 2
0 commit comments