diff --git a/chertex.sh b/chertex.sh index ce3ec1c..f545021 100755 --- a/chertex.sh +++ b/chertex.sh @@ -191,6 +191,20 @@ if [[ $show_menu == "false" ]]; then #### Special treatment for thesis if [[ $path_wd == "$path_thesis" && $jobname == "$dir_wd" ]]; then + # Restore thesis.bcf from latest commit if modified in workspace + # Background: any LaTeX run that finishes uncleanly (due to errors, etc.) leaves + # the bcf file in an incomplete state. Since we have at least one plot in the thesis + # that reads the bcf file, this in turn causes the subsequent chertex compilation + # to fail. This mess could be automatically avoided if we pre-emptively check + # if thesis.bcf is listed in the output of `git status --short`, and if so `git restore` it. + # https://stackoverflow.com/a/25149786/1198249 + if [[ `git status --porcelain | grep $jobname.bcf` ]]; then + msg " -------------------------------" + msg " Restoring thesis.bcf" + msg " -------------------------------" + git -C $path_wd restore $jobname.bcf + simpledelay.sh 2 + fi # Fetch external assets by reading any assets.external files in assets/ tree # NOTE: be careful NOT to leave empty lines in your assets.external files msg " -------------------------------"