From fe95cc472eafb1bd059882355518786f60a96c88 Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Sat, 14 May 2016 22:39:16 +0200 Subject: [PATCH] take --whole-tree into account when diffing with worktree We previously relied on ln_untracked to diff the worktree, but this is very fragile: first, this would break with --no-ln-untracked, and we were just symlinking *, hence did not manage properly subdirectories. Instead, copy the tracked files similarly to what we do to checkout a particular revision. $checkoutroot is set properly depending on whether --whole-tree is used, so this does the right thing. --- git-latexdiff | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/git-latexdiff b/git-latexdiff index e1e2472..55941fd 100755 --- a/git-latexdiff +++ b/git-latexdiff @@ -489,6 +489,7 @@ git_prefix=$(git rev-parse --show-prefix) git_dir="$(git rev-parse --git-dir)" || die "Not a git repository?" cd "$(git rev-parse --show-cdup)" || die "Can't cd back to repository root" git_dir=$(cd "$git_dir"; pwd) +git_worktree=$(pwd) # make main relative to git root directory if test -n "$git_prefix" ; then @@ -525,16 +526,18 @@ fi (cd "$git_dir" && git archive --format=tar "$old" "$checkoutroot") | tar -xf - verbose_progress cd ../new || die "Cannot cd to new/" +if test "$new" == "--"; then + # Copy working tree files + (cd "$git_worktree" && git ls-files -- "$checkoutroot" | tar -cf - -T -) | tar -xvf - +else + # checkout new revision + (cd "$git_dir" && git archive --format=tar "$new" "$checkoutroot") | tar -xf - +fi if test "$ln_untracked" = 1; then ( mkdir -p "$maindir" && cd "$maindir" && ln -s "$initial_repo"/"$maindir"/* . ) fi -if test "$new" != "--"; then - # if new == "--" then diff working dir (already there thanks to ln - # -s above). - (cd "$git_dir" && git archive --format=tar "$new" "$checkoutroot") | tar -xf - -fi verbose_progress cd ..