Skip to content

Commit a4cd5be

Browse files
davvidgitster
authored andcommitted
difftool: Wrap long lines for readability
Keep everything within 80 columns. Wrap the user-facing messages too. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 283abb2 commit a4cd5be

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

git-difftool.perl

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,22 @@ sub print_tool_help
9393
}
9494
}
9595

96-
print "'git difftool --tool=<tool>' may be set to one of the following:\n";
96+
print << 'EOF';
97+
'git difftool --tool=<tool>' may be set to one of the following:
98+
EOF
9799
print "\t$_\n" for (sort(@found));
98100

99-
print "\nThe following tools are valid, but not currently available:\n";
101+
print << 'EOF';
102+
103+
The following tools are valid, but not currently available:
104+
EOF
100105
print "\t$_\n" for (sort(@notfound));
101106

102-
print "\nNOTE: Some of the tools listed above only work in a windowed\n";
103-
print "environment. If run in a terminal-only session, they will fail.\n";
107+
print << 'EOF';
104108
109+
NOTE: Some of the tools listed above only work in a windowed
110+
environment. If run in a terminal-only session, they will fail.
111+
EOF
105112
exit(0);
106113
}
107114

@@ -114,8 +121,11 @@ sub setup_dir_diff
114121
# if $GIT_DIR and $GIT_WORK_TREE are set in ENV, they are actually used
115122
# by Git->repository->command*.
116123
my $repo_path = $repo->repo_path();
117-
my $diffrepo = Git->repository(Repository => $repo_path, WorkingCopy => $workdir);
118-
my $diffrtn = $diffrepo->command_oneline('diff', '--raw', '--no-abbrev', '-z', @ARGV);
124+
my %repo_args = (Repository => $repo_path, WorkingCopy => $workdir);
125+
my $diffrepo = Git->repository(%repo_args);
126+
127+
my @gitargs = ('diff', '--raw', '--no-abbrev', '-z', @ARGV);
128+
my $diffrtn = $diffrepo->command_oneline(@gitargs);
119129
exit(0) if (length($diffrtn) == 0);
120130

121131
# Setup temp directories
@@ -140,11 +150,15 @@ sub setup_dir_diff
140150
my $i = 0;
141151
while ($i < $#rawdiff) {
142152
if ($rawdiff[$i] =~ /^::/) {
143-
print "Combined diff formats ('-c' and '--cc') are not supported in directory diff mode.\n";
153+
warn << 'EOF';
154+
Combined diff formats ('-c' and '--cc') are not supported in
155+
directory diff mode ('-d' and '--dir-diff').
156+
EOF
144157
exit(1);
145158
}
146159

147-
my ($lmode, $rmode, $lsha1, $rsha1, $status) = split(' ', substr($rawdiff[$i], 1));
160+
my ($lmode, $rmode, $lsha1, $rsha1, $status) =
161+
split(' ', substr($rawdiff[$i], 1));
148162
my $src_path = $rawdiff[$i + 1];
149163
my $dst_path;
150164

@@ -156,7 +170,7 @@ sub setup_dir_diff
156170
$i += 2;
157171
}
158172

159-
if (($lmode eq $submodule_mode) or ($rmode eq $submodule_mode)) {
173+
if ($lmode eq $submodule_mode or $rmode eq $submodule_mode) {
160174
$submodule{$src_path}{left} = $lsha1;
161175
if ($lsha1 ne $rsha1) {
162176
$submodule{$dst_path}{right} = $rsha1;
@@ -167,14 +181,16 @@ sub setup_dir_diff
167181
}
168182

169183
if ($lmode eq $symlink_mode) {
170-
$symlink{$src_path}{left} = $diffrepo->command_oneline('show', "$lsha1");
184+
$symlink{$src_path}{left} =
185+
$diffrepo->command_oneline('show', "$lsha1");
171186
}
172187

173188
if ($rmode eq $symlink_mode) {
174-
$symlink{$dst_path}{right} = $diffrepo->command_oneline('show', "$rsha1");
189+
$symlink{$dst_path}{right} =
190+
$diffrepo->command_oneline('show', "$rsha1");
175191
}
176192

177-
if (($lmode ne $null_mode) and ($status !~ /^C/)) {
193+
if ($lmode ne $null_mode and $status !~ /^C/) {
178194
$lindex .= "$lmode $lsha1\t$src_path\0";
179195
}
180196

@@ -199,14 +215,16 @@ sub setup_dir_diff
199215
# Populate the left and right directories based on each index file
200216
my ($inpipe, $ctx);
201217
$ENV{GIT_INDEX_FILE} = "$tmpdir/lindex";
202-
($inpipe, $ctx) = $repo->command_input_pipe(qw/update-index -z --index-info/);
218+
($inpipe, $ctx) =
219+
$repo->command_input_pipe(qw(update-index -z --index-info));
203220
print($inpipe $lindex);
204221
$repo->command_close_pipe($inpipe, $ctx);
205222
my $rc = system('git', 'checkout-index', '--all', "--prefix=$ldir/");
206223
exit($rc | ($rc >> 8)) if ($rc != 0);
207224

208225
$ENV{GIT_INDEX_FILE} = "$tmpdir/rindex";
209-
($inpipe, $ctx) = $repo->command_input_pipe(qw/update-index -z --index-info/);
226+
($inpipe, $ctx) =
227+
$repo->command_input_pipe(qw(update-index -z --index-info));
210228
print($inpipe $rindex);
211229
$repo->command_close_pipe($inpipe, $ctx);
212230
$rc = system('git', 'checkout-index', '--all', "--prefix=$rdir/");

0 commit comments

Comments
 (0)