From f09fc140e1125e863effa06ed81419bc680ed1be Mon Sep 17 00:00:00 2001 From: William Henney Date: Thu, 17 Jul 2014 22:18:14 -0500 Subject: [PATCH] Two fixes to the handling of the --bbl option 1. Remove "old/" and "new/" prefixes from the --expand-bbl argument to latexpand. Not wanted since we have already changed to the relevant directory. 2. Allow for the case where the .bbl files are not stored in the repo. Try to regenerate them on the fly if they are missing. (Whitespace fixes by Matthieu Moy) --- git-latexdiff | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/git-latexdiff b/git-latexdiff index 488e0fa..83d1676 100755 --- a/git-latexdiff +++ b/git-latexdiff @@ -459,24 +459,46 @@ fi # Shortcut to include bbl if test "$bbl" = 1; then - oldbbl=("--expand-bbl old/"$mainbase".bbl") - newbbl=("--expand-bbl new/"$mainbase".bbl") + bblexpand=("--expand-bbl "$mainbase".bbl") else - oldbbl=("") - newbbl=("") + bblexpand=("") fi # Create flattened documents and keep for debugging if test "$flatten" = 1; then + if [ "$bbl" = 1 ]; then + if [ ! -f "old/"$maindir$mainbase".bbl" ]; then + verbose "Attempting to regenerate missing old/"$maindir$mainbase".bbl" + ( + cd old/"$maindir" + log_cmd pdflatex0.log pdflatex $latexopt "$mainbase" || compile_error=1 + log_cmd bibtex0.log bibtex "$mainbase" || compile_error=1 + ) + if [ "$compile_error" = 1 ]; then + die "Failed to regenerate .bbl for old version" + fi + fi + if [ ! -f "new/"$maindir$mainbase".bbl" ]; then + verbose "Attempting to regenerate missing new/"$maindir$mainbase".bbl" + ( + cd new/"$maindir" + log_cmd pdflatex0.log pdflatex $latexopt "$mainbase" || compile_error=1 + log_cmd bibtex0.log bibtex "$mainbase" || compile_error=1 + ) + if [ "$compile_error" = 1 ]; then + die "Failed to regenerate .bbl for new version" + fi + fi + fi verbose "Running latexpand" ( cd old/"$maindir" && - latexpand "$mainbase".tex "${latexpand[@]}" $oldbbl + latexpand "$mainbase".tex "${latexpand[@]}" $bblexpand ) > old-"$mainbase"-fl.tex \ || die "latexpand failed for old version" ( cd new/"$maindir" && - latexpand "$mainbase".tex "${latexpand[@]}" $newbbl + latexpand "$mainbase".tex "${latexpand[@]}" $bblexpand ) > new-"$mainbase"-fl.tex \ || die "latexpand failed for new version" verbose_done