Skip to content

Commit 9754908

Browse files
thenigangitster
authored andcommitted
contrib/diffall: eliminate duplicate while loops
There were 3 instances of a 'while read; do' that used identical logic to populate '/tmp/right_dir'. This commit groups them into a single loop. Signed-off-by: Tim Henigan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e33e01d commit 9754908

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

contrib/diffall/git-diffall

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,38 +179,32 @@ fi
179179
mkdir -p "$tmp/$left_dir" "$tmp/$right_dir"
180180

181181
# Populate the tmp/right_dir directory with the files to be compared
182-
if test -n "$right"
183-
then
184-
while read name
185-
do
182+
while read name
183+
do
184+
if test -n "$right"
185+
then
186186
ls_list=$(git ls-tree $right "$name")
187187
if test -n "$ls_list"
188188
then
189189
mkdir -p "$tmp/$right_dir/$(dirname "$name")"
190190
git show "$right":"$name" >"$tmp/$right_dir/$name" || true
191191
fi
192-
done < "$tmp/filelist"
193-
elif test -n "$compare_staged"
194-
then
195-
while read name
196-
do
192+
elif test -n "$compare_staged"
193+
then
197194
ls_list=$(git ls-files -- "$name")
198195
if test -n "$ls_list"
199196
then
200197
mkdir -p "$tmp/$right_dir/$(dirname "$name")"
201198
git show :"$name" >"$tmp/$right_dir/$name"
202199
fi
203-
done < "$tmp/filelist"
204-
else
205-
while read name
206-
do
200+
else
207201
if test -e "$name"
208202
then
209203
mkdir -p "$tmp/$right_dir/$(dirname "$name")"
210204
cp "$name" "$tmp/$right_dir/$name"
211205
fi
212-
done < "$tmp/filelist"
213-
fi
206+
fi
207+
done < "$tmp/filelist"
214208

215209
# Populate the tmp/left_dir directory with the files to be compared
216210
while read name

0 commit comments

Comments
 (0)