diff --git a/git-latexdiff b/git-latexdiff index 41fbeb6..488c548 100755 --- a/git-latexdiff +++ b/git-latexdiff @@ -399,6 +399,8 @@ cd "$(git rev-parse --show-cdup)" || die "Can't cd back to repository root" git_dir=$(cd "$git_dir"; pwd) main=$git_prefix/$main +mainbase=$(basename "$main" .tex) +maindir=$(dirname "$main") tmpdir=$tmpdir_prefix/git-latexdiff.$$ mkdir "$tmpdir" || die "Cannot create temporary directory." @@ -413,7 +415,9 @@ verbose "Checking out old and new version" cd old || die "Cannot cd to old/" if test "$ln_untracked" = 1; then - ln -s "$initial_dir"/* . + ( + mkdir -p "$maindir" && cd "$maindir" && ln -s "$initial_dir"/* . + ) fi if test "$subtree" = 1; then @@ -427,7 +431,9 @@ fi verbose_progress cd ../new || die "Cannot cd to new/" if test "$ln_untracked" = 1; then - ln -s "$initial_dir"/* . + ( + mkdir -p "$maindir" && cd "$maindir" && ln -s "$initial_dir"/* . + ) fi if test "$new" != "--"; then # if new == "--" then diff working dir (already there thanks to ln @@ -449,9 +455,6 @@ do verbose_done done -mainbase=$(basename "$main" .tex) -maindir=$(dirname "$main") - # Option to use latexdiff --flatten instead of latexpand if test "$latexdiff_flatten" = 1; then latexdiffopt+=("--flatten") diff --git a/tests/bib/run-test.sh b/tests/bib/run-test.sh index 75694ad..7e05500 100755 --- a/tests/bib/run-test.sh +++ b/tests/bib/run-test.sh @@ -2,26 +2,39 @@ die () { echo "fatal: $@" + cleanup exit 1 } +cleanup () { + perl -pi -e 's/Uncommited/New/g' test.tex test.bbl +} + +trap cleanup 2 + +perl -pi -e 's/New/Uncommited/g' test.tex test.bbl oldnew="$(git rev-list HEAD -- test.tex test.bbl)" old=$(echo "$oldnew" | sed -n '1p') new=$(echo "$oldnew" | sed -n '2p') rm -f *.aux *.bbl echo "git latexdiff without --bbl option (should not display bibliography)" -../../git-latexdiff $old $new 2>&1 > no-bbl.log || +../../git-latexdiff -v $old $new 2>&1 > no-bbl.log || die "latexdiff without --bbl failed (log in no-bbl.log)." rm -f *.aux *.bbl echo "git latexdiff with --bbl option (should display diff within bibliography)" -../../git-latexdiff $old $new --bbl 2>&1 > with-bbl.log || +../../git-latexdiff -v $old $new --bbl 2>&1 > with-bbl.log || die "latexdiff with --bbl failed (log in with-bbl.log)." rm -f *.aux *.bbl echo "git latexdiff with --latexdiff-flatten option (should not display bibliography)" -../../git-latexdiff $old $new --latexdiff-flatten 2>&1 > with-flatten.log || +../../git-latexdiff -v $old $new --latexdiff-flatten 2>&1 > with-flatten.log || die "latexdiff with --latexdiff-flatten failed (log in flatten.log)." +echo "git latexdiff --bbl against the working directory (should display new -> uncommited changes)" +../../git-latexdiff -v --bbl HEAD -- 2>&1 > workdir.log || + die "git latexdiff --bbl against the working directory failed (log in workdir.log)." + +cleanup diff --git a/tests/bib/test.bib b/tests/bib/test.bib index c984129..c515a46 100644 --- a/tests/bib/test.bib +++ b/tests/bib/test.bib @@ -1,5 +1,5 @@ @Article{test-entry, - author = {New author}, + author = {Uncommited author}, title = {Some title}, journal = {Some journal}, year = 42}