@@ -37,14 +37,6 @@ sub usage
3737 exit ($exitcode );
3838}
3939
40- sub find_worktree
41- {
42- # Git->repository->wc_path() does not honor changes to the working
43- # tree location made by $ENV{GIT_WORK_TREE} or the 'core.worktree'
44- # config variable.
45- return Git::command_oneline(' rev-parse' , ' --show-toplevel' );
46- }
47-
4840sub print_tool_help
4941{
5042 # See the comment at the bottom of file_diff() for the reason behind
@@ -67,14 +59,14 @@ sub exit_cleanup
6759
6860sub use_wt_file
6961{
70- my ($repo , $ workdir , $file , $sha1 ) = @_ ;
62+ my ($workdir , $file , $sha1 ) = @_ ;
7163 my $null_sha1 = ' 0' x 40 ;
7264
7365 if (-l " $workdir /$file " || ! -e _) {
7466 return (0, $null_sha1 );
7567 }
7668
77- my $wt_sha1 = $repo -> command_oneline(' hash-object' , " $workdir /$file " );
69+ my $wt_sha1 = Git:: command_oneline(' hash-object' , " $workdir /$file " );
7870 my $use = ($sha1 eq $null_sha1 ) || ($sha1 eq $wt_sha1 );
7971 return ($use , $wt_sha1 );
8072}
@@ -108,11 +100,9 @@ sub changed_files
108100
109101sub setup_dir_diff
110102{
111- my ($repo , $workdir , $symlinks ) = @_ ;
112-
113- my $repo_path = $repo -> repo_path();
103+ my ($workdir , $symlinks ) = @_ ;
114104 my @gitargs = (' diff' , ' --raw' , ' --no-abbrev' , ' -z' , @ARGV );
115- my $diffrtn = $repo -> command_oneline(@gitargs );
105+ my $diffrtn = Git:: command_oneline(@gitargs );
116106 exit (0) unless defined ($diffrtn );
117107
118108 # Build index info for left and right sides of the diff
@@ -164,12 +154,12 @@ sub setup_dir_diff
164154
165155 if ($lmode eq $symlink_mode ) {
166156 $symlink {$src_path }{left } =
167- $repo -> command_oneline(' show' , " $lsha1 " );
157+ Git:: command_oneline(' show' , $lsha1 );
168158 }
169159
170160 if ($rmode eq $symlink_mode ) {
171161 $symlink {$dst_path }{right } =
172- $repo -> command_oneline(' show' , " $rsha1 " );
162+ Git:: command_oneline(' show' , $rsha1 );
173163 }
174164
175165 if ($lmode ne $null_mode and $status !~ / ^C/ ) {
@@ -181,8 +171,8 @@ sub setup_dir_diff
181171 if ($working_tree_dups {$dst_path }++) {
182172 next ;
183173 }
184- my ($use , $wt_sha1 ) = use_wt_file( $repo , $workdir ,
185- $dst_path , $rsha1 );
174+ my ($use , $wt_sha1 ) =
175+ use_wt_file( $workdir , $dst_path , $rsha1 );
186176 if ($use ) {
187177 push @working_tree , $dst_path ;
188178 $wtindex .= " $rmode $wt_sha1 \t $dst_path \0 " ;
@@ -203,27 +193,27 @@ sub setup_dir_diff
203193 my ($inpipe , $ctx );
204194 $ENV {GIT_INDEX_FILE } = " $tmpdir /lindex" ;
205195 ($inpipe , $ctx ) =
206- $repo -> command_input_pipe(qw( update-index -z --index-info) );
196+ Git:: command_input_pipe(' update-index' , ' -z ' , ' --index-info' );
207197 print ($inpipe $lindex );
208- $repo -> command_close_pipe($inpipe , $ctx );
198+ Git:: command_close_pipe($inpipe , $ctx );
209199
210200 my $rc = system (' git' , ' checkout-index' , ' --all' , " --prefix=$ldir /" );
211201 exit_cleanup($tmpdir , $rc ) if $rc != 0;
212202
213203 $ENV {GIT_INDEX_FILE } = " $tmpdir /rindex" ;
214204 ($inpipe , $ctx ) =
215- $repo -> command_input_pipe(qw( update-index -z --index-info) );
205+ Git:: command_input_pipe(' update-index' , ' -z ' , ' --index-info' );
216206 print ($inpipe $rindex );
217- $repo -> command_close_pipe($inpipe , $ctx );
207+ Git:: command_close_pipe($inpipe , $ctx );
218208
219209 $rc = system (' git' , ' checkout-index' , ' --all' , " --prefix=$rdir /" );
220210 exit_cleanup($tmpdir , $rc ) if $rc != 0;
221211
222212 $ENV {GIT_INDEX_FILE } = " $tmpdir /wtindex" ;
223213 ($inpipe , $ctx ) =
224- $repo -> command_input_pipe(qw( update-index --info-only -z --index-info) );
214+ Git:: command_input_pipe(' update-index' , ' --info-only' , ' -z ' , ' --index-info' );
225215 print ($inpipe $wtindex );
226- $repo -> command_close_pipe($inpipe , $ctx );
216+ Git:: command_close_pipe($inpipe , $ctx );
227217
228218 # If $GIT_DIR was explicitly set just for the update/checkout
229219 # commands, then it should be unset before continuing.
@@ -393,9 +383,9 @@ sub dir_diff
393383 my $rc ;
394384 my $error = 0;
395385 my $repo = Git-> repository();
396- my $workdir = find_worktree ();
397- my ( $a , $b , $tmpdir , @worktree ) =
398- setup_dir_diff( $repo , $workdir , $symlinks );
386+ my $repo_path = $repo -> repo_path ();
387+ my $workdir = $repo -> wc_path();
388+ my ( $a , $b , $tmpdir , @worktree ) = setup_dir_diff( $workdir , $symlinks );
399389
400390 if (defined ($extcmd )) {
401391 $rc = system ($extcmd , $a , $b );
@@ -421,10 +411,10 @@ sub dir_diff
421411 next if ! -f " $b /$file " ;
422412
423413 if (!$indices_loaded ) {
424- %wt_modified = changed_files($repo -> repo_path(),
425- " $tmpdir /wtindex" , " $workdir " );
426- %tmp_modified = changed_files($repo -> repo_path(),
427- " $tmpdir /wtindex" , " $b " );
414+ %wt_modified = changed_files(
415+ $repo_path , " $tmpdir /wtindex" , $workdir );
416+ %tmp_modified = changed_files(
417+ $repo_path , " $tmpdir /wtindex" , $b );
428418 $indices_loaded = 1;
429419 }
430420
0 commit comments