Skip to content

Commit 1148132

Browse files
committed
Rename some variables
1 parent 99b7b18 commit 1148132

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

git-fmt-diff

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -275,51 +275,51 @@ detect_filetype () (
275275

276276
git_changes_formatted () (
277277
tempdir="$1"
278-
b="$2"
279-
a="$3"
278+
b_raw="$2"
279+
a_raw="$3"
280280
b_fmt="$4"
281281
a_fmt="$5"
282282

283283
merge () { git merge-file -p "$@"; }
284-
diff_fmt="$tempdir"/diff_fmt
284+
chng_fmt="$tempdir"/chng_fmt
285285
temp="$tempdir"/temp
286286

287287
rm_list__push "$temp"
288-
rm_list__push "$diff_fmt"
288+
rm_list__push "$chng_fmt"
289289

290290
if git diff -s "$b_fmt" "$a_fmt"; then
291-
merge --our "$b" "$a" "$b_fmt" > "$temp"
292-
merge "$b" "$temp" "$b_fmt" > "$diff_fmt"
293-
echo "$diff_fmt"
291+
merge --our "$b_raw" "$a_raw" "$b_fmt" > "$temp"
292+
merge "$b_raw" "$temp" "$b_fmt" > "$chng_fmt"
293+
echo "$chng_fmt"
294294
return
295295
fi
296296

297-
merge --their "$a" "$a_fmt" "$b_fmt" > "$diff_fmt"
297+
merge --their "$a_raw" "$a_fmt" "$b_fmt" > "$chng_fmt"
298298

299-
merge --our "$diff_fmt" "$a" "$b" > "$temp"
300-
if ! git diff -s "$diff_fmt" "$temp"; then
301-
merge --their "$b" "$diff_fmt" "$b_fmt" > "$temp"
302-
merge --their "$b" "$temp" "$b_fmt" > "$diff_fmt"
299+
merge --our "$chng_fmt" "$a_raw" "$b_raw" > "$temp"
300+
if ! git diff -s "$chng_fmt" "$temp"; then
301+
merge --their "$b_raw" "$chng_fmt" "$b_fmt" > "$temp"
302+
merge --their "$b_raw" "$temp" "$b_fmt" > "$chng_fmt"
303303
fi
304304

305-
merge --our "$a" "$a_fmt" "$b" > "$temp"
306-
if ! git diff -s "$diff_fmt" "$temp"; then
307-
echo "$diff_fmt"
305+
merge --our "$a_raw" "$a_fmt" "$b_raw" > "$temp"
306+
if ! git diff -s "$chng_fmt" "$temp"; then
307+
echo "$chng_fmt"
308308
fi
309309
)
310310

311311
git_diff () (
312-
b="$1"
313-
diff_fmt="$2"
312+
b_raw="$1"
313+
chng_fmt="$2"
314314
filename="$3"
315315

316316
[ "$gf_use_color" = 1 ] && color="--color" || color=
317317

318318
# shellcheck disable=SC2086
319-
git diff $color "$b" "$diff_fmt" | \
319+
git diff $color "$b_raw" "$chng_fmt" | \
320320
sed \
321-
-e "s/$(sed_esc -p "a$b")/$(sed_esc -s "a/$filename")/g" \
322-
-e "s/$(sed_esc -p "b$diff_fmt")/$(sed_esc -s "b/$filename")/g"
321+
-e "s/$(sed_esc -p "a$b_raw")/$(sed_esc -s "a/$filename")/g" \
322+
-e "s/$(sed_esc -p "b$chng_fmt")/$(sed_esc -s "b/$filename")/g"
323323
)
324324

325325
git_retrieve_file_from_sha () (
@@ -357,8 +357,8 @@ list_files () (
357357
)
358358

359359
process_file () (
360-
sha1="$1"
361-
sha2="$2"
360+
a_hash="$1"
361+
b_hash="$2"
362362
a_name="$3"
363363
b_name="${4:-$a_name}"
364364

@@ -386,33 +386,34 @@ process_file () (
386386

387387
debug "$b_name => $tempdir"
388388

389-
b="$tempdir"/b
390-
a="$tempdir"/a
389+
b_raw="$tempdir"/b_raw
390+
a_raw="$tempdir"/a_raw
391391
b_fmt="$tempdir"/b_fmt
392392
a_fmt="$tempdir"/a_fmt
393393

394-
git_retrieve_file_from_sha "$sha1" "" > "$a"
395-
git_retrieve_file_from_sha "$sha2" "$b_name" > "$b"
396-
rm_list__push "$a" "$b"
394+
git_retrieve_file_from_sha "$a_hash" "" > "$a_raw"
395+
git_retrieve_file_from_sha "$b_hash" "$b_name" > "$b_raw"
396+
rm_list__push "$a_raw" "$b_raw"
397397

398-
if [ ! -s "$b" ]; then
399-
warn "couldn't retrieve ${obj2:+$obj2:}$b_name"
398+
if [ ! -s "$b_raw" ]; then
399+
warn "couldn't retrieve $b_name"
400400
fi
401401

402-
sh -c "$formatter" < "$b" > "$b_fmt" 2> /dev/null
402+
sh -c "$formatter" < "$b_raw" > "$b_fmt" 2> /dev/null
403403
rm_list__push "$b_fmt"
404404

405-
if ! git diff -s "$b" "$b_fmt"; then
406-
sh -c "$formatter" < "$a" > "$a_fmt" 2> /dev/null
405+
if ! git diff -s "$b_raw" "$b_fmt"; then
406+
sh -c "$formatter" < "$a_raw" > "$a_fmt" 2> /dev/null
407407
rm_list__push "$a_fmt"
408408

409-
diff_fmt="$(git_changes_formatted \
409+
chng_fmt="$(git_changes_formatted \
410410
"$tempdir" \
411-
"$b" "$a" "$b_fmt" "$a_fmt" \
411+
"$b_raw" "$a_raw" \
412+
"$b_fmt" "$a_fmt" \
412413
)"
413414

414-
if [ -n "$diff_fmt" ]; then
415-
git_diff "$b" "$diff_fmt" "$b_name"
415+
if [ -n "$chng_fmt" ]; then
416+
git_diff "$b_raw" "$chng_fmt" "$b_name"
416417
fi
417418
fi
418419
)

0 commit comments

Comments
 (0)