Skip to content

Commit 972a138

Browse files
committed
Fix cleaning temp files
1 parent a23b1fd commit 972a138

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

git-fmt-diff

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ gf_use_color=
1919

2020
# helpers {{{1
2121

22-
abspath() (
22+
abspath () (
2323
if [ -d "$1" ]; then
2424
cd "$1" && pwd
2525
elif [ -f "$1" ]; then
@@ -297,7 +297,9 @@ git_retrieve_file_from_obj () (
297297
debug "obj = '$obj'"
298298
debug "file = '$file'"
299299

300-
if [ -n "$obj" ]; then
300+
if [ -e "$file" ] && [ "$obj" = "$file" ]; then
301+
cat "$file"
302+
elif [ -n "$obj" ]; then
301303
git show "$obj:$file" 2> /dev/null
302304
elif [ -e "$file" ]; then
303305
cat "$file"
@@ -348,19 +350,21 @@ process_file () (
348350

349351
sh -c "$formatter" < "$cur" > "$cur_fmt" 2> /dev/null
350352

351-
if git diff -s "$cur" "$cur_fmt"; then
352-
return
353-
fi
353+
if ! git diff -s "$cur" "$cur_fmt"; then
354+
sh -c "$formatter" < "$old" > "$old_fmt" 2> /dev/null
354355

355-
sh -c "$formatter" < "$old" > "$old_fmt" 2> /dev/null
356+
git_changes_formatted "$tempdir" "$cur" "$old" "$cur_fmt" "$old_fmt" > "$fmt"
356357

357-
git_changes_formatted "$tempdir" "$cur" "$old" "$cur_fmt" "$old_fmt" > "$fmt"
358+
if [ -s "$fmt" ]; then
359+
git_diff "$cur" "$fmt" "$cur_name"
360+
fi
358361

359-
git_diff "$cur" "$fmt" "$cur_name"
362+
[ "$gf_debug" != 1 ] && rm "$old_fmt" "$fmt"
363+
fi
360364

361365
debug "$cur_name => $tempdir"
362366
if [ "$gf_debug" != 1 ]; then
363-
rm "$old" "$cur" "$cur_fmt" "$old_fmt" "$fmt"
367+
rm "$old" "$cur" "$cur_fmt"
364368
rmdir "$tempdir"
365369
fi
366370
)
@@ -388,7 +392,8 @@ list_files () (
388392
)
389393

390394
usage () (
391-
true # TODO
395+
cat << EOU
396+
EOU
392397
)
393398

394399
parse_options () {

0 commit comments

Comments
 (0)