Skip to content

Commit 76ba3bf

Browse files
committed
Fix git-size behaviour for empty files
1 parent 7ae0774 commit 76ba3bf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

git-size

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/bash
22

3-
args=$(git rev-parse --short "$@")
4-
eval "git diff-tree -r $args" | {
3+
# args=$(git rev-parse --short "$@")
4+
5+
eval "git diff-tree -r $@" | {
56
total=0
6-
while read A B C D M P
7-
do
7+
while read A B C D M P; do
88
if [[ -z $M ]]; then continue; fi
99
case $M in
10-
M) bytes=$(( $(git cat-file -s $D) - $(git cat-file -s $C) )) ;;
10+
M) bytes=$(( $(git cat-file -s $D || echo 0) - $(git cat-file -s $C || echo 0) )) ;;
1111
A) bytes=$(git cat-file -s $D) ;;
1212
D) bytes=-$(git cat-file -s $C) ;;
1313
*)
@@ -22,6 +22,6 @@ eval "git diff-tree -r $args" | {
2222
if (( $total < 1000 )); then
2323
echo ${total} bytes
2424
else
25-
echo $(( total / 1000))KB
25+
echo $(( total / 1000 ))KB
2626
fi
2727
}

0 commit comments

Comments
 (0)