Created
December 4, 2016 13:14
-
-
Save teknikqa/4f7a218c0c4479f3945a81e856f0dcf5 to your computer and use it in GitHub Desktop.
Creates a diffed latex document comparing your recent uncommitted changes to your git last commit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#This script creates a diffed latex document comparing your recent uncommitted changes to your git last commit. | |
# | |
# ./gitLatexDiff.sh "folder path containing the git repository" | |
# | |
#You need to make sure that the current version at least compiles. | |
# | |
#The file and folder structure: | |
# | |
# $1/Figures/* | |
# $1/*.tex | |
# | |
# ROOTFILE will be the "master" that gets compiled. | |
# riboch | |
CURRDIR=$(pwd) | |
CLONEDDIR=ClonedDirectory | |
ROOTFILE=root.tex | |
DIFFEDFILE=diff.tex | |
mkdir $CLONEDDIR | |
cd $CLONEDDIR | |
git clone $1 | |
cd "$(ls)" | |
#I recommend not tracking the figures: | |
# git update-index --assume-unchanged FILENAME | |
mkdir Figures/ | |
cp $(echo $1)/Figures/* Figures/ | |
for a1 in $(ls *.tex); | |
do | |
if [ "$a1" != "$ROOTFILE" ] | |
then | |
echo $a1 | |
#Goes back 1 revision in case you commited already, you fool. | |
#git checkout HEAD~1 $a1 | |
NEWDIFFFILE="DIFF$(basename $a1 .tex).tex" | |
echo $NEWDIFFFILE | |
mv $a1 $NEWDIFFFILE | |
#Takes difference between last commit and what is in the working directory. | |
#Does not check math environments, need --math-markup=3 for bug-#726313 | |
latexdiff --math-markup=3 $NEWDIFFFILE "$1/$a1" > $a1 | |
else | |
latexdiff --math-markup=3 "$ROOTFILE" "$1/$ROOTFILE" > $DIFFEDFILE | |
fi | |
done | |
#Compile the diffed version. | |
lualatex -interaction=nonstopmode $DIFFEDFILE | |
bibtex $(basename $DIFFEDFILE .tex).aux | |
lualatex -interaction=nonstopmode $DIFFEDFILE | |
lualatex -interaction=nonstopmode $DIFFEDFILE | |
mv $(basename $DIFFEDFILE .tex).pdf $1/difference.pdf | |
cd $CURRDIR | |
rm -rf $CLONEDDIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment