Skip to content

Commit a4caa52

Browse files
author
Junio C Hamano
committed
git-count-objects: dc replacement
Johannes suggested this earlier but I did not take it so seriously because this command is not that important. But this probably matters on Cygwin which does not seem to come with precompiled dc. It is a mystery for me that anything that mimics UNIX does not offer a dc, though. I did the detection for the lack of dc command a bit differently from the verison Johannes did. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 3eeb419 commit a4caa52

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

git-count-objects.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
#!/bin/sh
2+
#
3+
# Copyright (c) 2005 Junio C Hamano
4+
#
25

3-
. git-sh-setup
6+
. git-sh-setup || die "Not a git repository"
7+
8+
dc </dev/null 2>/dev/null || {
9+
# This is not a real DC at all -- it just knows how
10+
# this script feeds DC and does the computation itself.
11+
dc () {
12+
while read a b
13+
do
14+
case $a,$b in
15+
0,) acc=0 ;;
16+
*,+) acc=$(($acc + $a)) ;;
17+
p,) echo "$acc" ;;
18+
esac
19+
done
20+
}
21+
}
422

523
echo $(find "$GIT_DIR/objects"/?? -type f -print 2>/dev/null | wc -l) objects, \
624
$({

0 commit comments

Comments
 (0)