From 3584933c5c869aba704ee84965e4602ba244ecca Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Sat, 8 Feb 2020 11:28:10 +0100 Subject: [PATCH] Fix path to PDF file (hopefully) in all conditions We need the code to work * When the command is called from the toplevel ($git_prefix empty) or not * With --whole-tree or not * With --build-dir (relative) or not We do need to cd to the place in new/ corresponding to where the command was called in the original repository to allow using "$builddir/$mainbase".pdf as a relative path, but we need to compute $builddir properly in all cases. This patch should do this. --- git-latexdiff | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/git-latexdiff b/git-latexdiff index 4971b67..18960b3 100755 --- a/git-latexdiff +++ b/git-latexdiff @@ -576,6 +576,7 @@ cd "$(git rev-parse --show-cdup)" || die "Can't cd back to repository root" git_dir=$(cd "$git_dir"; pwd) git_worktree=$(pwd) +relative_main_dir=$(dirname "$main") # make main relative to git root directory if test -n "$git_prefix" ; then main=$git_prefix$main @@ -609,20 +610,14 @@ fi if test "$subtree" = 1 && test -n "$git_prefix"; then checkoutroot=$git_prefix - # create the build directory (containing the final PDFs) if the param was set - if test -n "$use_build_dir" ; then - builddir="$git_prefix/$use_build_dir" - else - builddir="$git_prefix" - fi else checkoutroot="." - # create the build directory (containing the final PDFs) if the param was set - if test -n "$use_build_dir" ; then - builddir="$use_build_dir" - else - builddir="." - fi +fi +# create the build directory (containing the final PDFs) if the param was set +if test -n "$use_build_dir" ; then + builddir="$use_build_dir" +else + builddir="$relative_main_dir" fi # Checkout a subtree, without touching the index ("git checkout" would)