git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] difftool: fix argument handling in subdirs

From
David Aguilar <davvid@gmail.com>
Date
Jul 19, 2016, 03:57 UTC
Message-ID
<20160719035756.24961-1-davvid@gmail.com>
From: John Keeping <john@keeping.me.uk>

When in a subdirectory of a repository, path arguments should be interpreted relative to the current directory not the root of the working tree.

The Git::repository object passed into setup_dir_diff() is configured to handle this correctly but we create a new Git::repository here without setting the WorkingSubdir argument. By simply using the existing repository, path arguments are handled relative to the current directory.

Reported-by: Bernhard Kirchen <bernhard.kirchen@rwth-aachen.de>
Signed-off-by: John Keeping <john@keeping.me.uk>
Acked-by: David Aguilar <davvid@gmail.com>
---
This patch is unchanged from John's version but also includes
Reported-by and Acked-by lines.
 git-difftool.perl | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index ebd13ba..c9d3ef8 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -115,16 +115,9 @@ sub setup_dir_diff
 {
 	my ($repo, $workdir, $symlinks) = @_;
 
-	# Run the diff; exit immediately if no diff found
-	# 'Repository' and 'WorkingCopy' must be explicitly set to insure that
-	# if $GIT_DIR and $GIT_WORK_TREE are set in ENV, they are actually used
-	# by Git->repository->command*.
 	my $repo_path = $repo->repo_path();
-	my %repo_args = (Repository => $repo_path, WorkingCopy => $workdir);
-	my $diffrepo = Git->repository(%repo_args);
-
 	my @gitargs = ('diff', '--raw', '--no-abbrev', '-z', @ARGV);
-	my $diffrtn = $diffrepo->command_oneline(@gitargs);
+	my $diffrtn = $repo->command_oneline(@gitargs);
 	exit(0) unless defined($diffrtn);
 
 	# Build index info for left and right sides of the diff
@@ -176,12 +169,12 @@ EOF
 
 		if ($lmode eq $symlink_mode) {
 			$symlink{$src_path}{left} =
-				$diffrepo->command_oneline('show', "$lsha1");
+				$repo->command_oneline('show', "$lsha1");
 		}
 
 		if ($rmode eq $symlink_mode) {
 			$symlink{$dst_path}{right} =
-				$diffrepo->command_oneline('show', "$rsha1");
+				$repo->command_oneline('show', "$rsha1");
 		}
 
 		if ($lmode ne $null_mode and $status !~ /^C/) {
-- 
2.9.2.280.g385e27a
Next: David Aguilar
Message 1 of 8 in “difftool: fix argument handling in subdirs”
  1. 1/3 difftool: fix argument handling in subdirsDavid Aguilar, Jul 19, 2016
  2. 2/3 difftool: avoid $GIT_DIR and $GIT_WORK_TREEDavid Aguilar, Jul 19, 2016
  3. Junio C HamanoJul 19, 2016
  4. Junio C HamanoJul 19, 2016
  5. David AguilarJul 20, 2016
  6. 3/3 difftool: use Git::* functions instead of passing around stateDavid Aguilar, Jul 19, 2016
  7. Junio C HamanoJul 19, 2016
  8. Junio C HamanoJul 19, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.