@@ -37,14 +37,6 @@ sub usage
37
37
exit ($exitcode );
38
38
}
39
39
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
-
48
40
sub print_tool_help
49
41
{
50
42
# See the comment at the bottom of file_diff() for the reason behind
@@ -67,14 +59,14 @@ sub exit_cleanup
67
59
68
60
sub use_wt_file
69
61
{
70
- my ($repo , $ workdir , $file , $sha1 ) = @_ ;
62
+ my ($workdir , $file , $sha1 ) = @_ ;
71
63
my $null_sha1 = ' 0' x 40 ;
72
64
73
65
if (-l " $workdir /$file " || ! -e _) {
74
66
return (0, $null_sha1 );
75
67
}
76
68
77
- my $wt_sha1 = $repo -> command_oneline(' hash-object' , " $workdir /$file " );
69
+ my $wt_sha1 = Git:: command_oneline(' hash-object' , " $workdir /$file " );
78
70
my $use = ($sha1 eq $null_sha1 ) || ($sha1 eq $wt_sha1 );
79
71
return ($use , $wt_sha1 );
80
72
}
@@ -108,11 +100,9 @@ sub changed_files
108
100
109
101
sub setup_dir_diff
110
102
{
111
- my ($repo , $workdir , $symlinks ) = @_ ;
112
-
113
- my $repo_path = $repo -> repo_path();
103
+ my ($workdir , $symlinks ) = @_ ;
114
104
my @gitargs = (' diff' , ' --raw' , ' --no-abbrev' , ' -z' , @ARGV );
115
- my $diffrtn = $repo -> command_oneline(@gitargs );
105
+ my $diffrtn = Git:: command_oneline(@gitargs );
116
106
exit (0) unless defined ($diffrtn );
117
107
118
108
# Build index info for left and right sides of the diff
@@ -164,12 +154,12 @@ sub setup_dir_diff
164
154
165
155
if ($lmode eq $symlink_mode ) {
166
156
$symlink {$src_path }{left } =
167
- $repo -> command_oneline(' show' , " $lsha1 " );
157
+ Git:: command_oneline(' show' , $lsha1 );
168
158
}
169
159
170
160
if ($rmode eq $symlink_mode ) {
171
161
$symlink {$dst_path }{right } =
172
- $repo -> command_oneline(' show' , " $rsha1 " );
162
+ Git:: command_oneline(' show' , $rsha1 );
173
163
}
174
164
175
165
if ($lmode ne $null_mode and $status !~ / ^C/ ) {
@@ -181,8 +171,8 @@ sub setup_dir_diff
181
171
if ($working_tree_dups {$dst_path }++) {
182
172
next ;
183
173
}
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 );
186
176
if ($use ) {
187
177
push @working_tree , $dst_path ;
188
178
$wtindex .= " $rmode $wt_sha1 \t $dst_path \0 " ;
@@ -203,27 +193,27 @@ sub setup_dir_diff
203
193
my ($inpipe , $ctx );
204
194
$ENV {GIT_INDEX_FILE } = " $tmpdir /lindex" ;
205
195
($inpipe , $ctx ) =
206
- $repo -> command_input_pipe(qw( update-index -z --index-info) );
196
+ Git:: command_input_pipe(' update-index' , ' -z ' , ' --index-info' );
207
197
print ($inpipe $lindex );
208
- $repo -> command_close_pipe($inpipe , $ctx );
198
+ Git:: command_close_pipe($inpipe , $ctx );
209
199
210
200
my $rc = system (' git' , ' checkout-index' , ' --all' , " --prefix=$ldir /" );
211
201
exit_cleanup($tmpdir , $rc ) if $rc != 0;
212
202
213
203
$ENV {GIT_INDEX_FILE } = " $tmpdir /rindex" ;
214
204
($inpipe , $ctx ) =
215
- $repo -> command_input_pipe(qw( update-index -z --index-info) );
205
+ Git:: command_input_pipe(' update-index' , ' -z ' , ' --index-info' );
216
206
print ($inpipe $rindex );
217
- $repo -> command_close_pipe($inpipe , $ctx );
207
+ Git:: command_close_pipe($inpipe , $ctx );
218
208
219
209
$rc = system (' git' , ' checkout-index' , ' --all' , " --prefix=$rdir /" );
220
210
exit_cleanup($tmpdir , $rc ) if $rc != 0;
221
211
222
212
$ENV {GIT_INDEX_FILE } = " $tmpdir /wtindex" ;
223
213
($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' );
225
215
print ($inpipe $wtindex );
226
- $repo -> command_close_pipe($inpipe , $ctx );
216
+ Git:: command_close_pipe($inpipe , $ctx );
227
217
228
218
# If $GIT_DIR was explicitly set just for the update/checkout
229
219
# commands, then it should be unset before continuing.
@@ -393,9 +383,9 @@ sub dir_diff
393
383
my $rc ;
394
384
my $error = 0;
395
385
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 );
399
389
400
390
if (defined ($extcmd )) {
401
391
$rc = system ($extcmd , $a , $b );
@@ -421,10 +411,10 @@ sub dir_diff
421
411
next if ! -f " $b /$file " ;
422
412
423
413
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 );
428
418
$indices_loaded = 1;
429
419
}
430
420
0 commit comments