Merge branch 'jk/difftool-in-subdir'
authorJunio C Hamano <gitster@pobox.com>
Tue, 27 Dec 2016 08:11:43 +0000 (00:11 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Dec 2016 08:11:43 +0000 (00:11 -0800)
Even though an fix was attempted in Git 2.9.3 days, but running
"git difftool --dir-diff" from a subdirectory never worked. This
has been fixed.

* jk/difftool-in-subdir:
difftool: rename variables for consistency
difftool: chdir as early as possible
difftool: sanitize $workdir as early as possible
difftool: fix dir-diff index creation when in a subdirectory

1  2 
git-difftool.perl
index 674828de3920634505291eee03f8ea908430d938,4e4f5d8138a68e52e5ec0b787c1d7a09ba3e6658..df59bdfe97786b5d9f48777cfad80545ff6bbdc2
@@@ -183,10 -188,6 +189,10 @@@ EO
                }
        }
  
-       chdir($workdir);
 +      # Go to the root of the worktree so that the left index files
 +      # are properly setup -- the index is toplevel-relative.
++      chdir($worktree);
 +
        # Setup temp directories
        my $tmpdir = tempdir('git-difftool.XXXXX', CLEANUP => 0, TMPDIR => 1);
        my $ldir = "$tmpdir/left";
@@@ -424,11 -424,11 +429,11 @@@ sub dir_dif
                }
  
                if (exists $wt_modified{$file} and exists $tmp_modified{$file}) {
 -                      my $errmsg = "warning: Both files modified: ";
 -                      $errmsg .= "'$worktree/$file' and '$b/$file'.\n";
 -                      $errmsg .= "warning: Working tree file has been left.\n";
 -                      $errmsg .= "warning:\n";
 -                      warn $errmsg;
 +                      warn sprintf(__(
 +                              "warning: Both files modified:\n" .
 +                              "'%s/%s' and '%s/%s'.\n" .
 +                              "warning: Working tree file has been left.\n" .
-                               "warning:\n"), $workdir, $file, $b, $file);
++                              "warning:\n"), $worktree, $file, $b, $file);
                        $error = 1;
                } elsif (exists $tmp_modified{$file}) {
                        my $mode = stat("$b/$file")->mode;