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>
Junio C Hamano committed
Nov 19, 2005 at 02:54 UTC
a4caa5214058ad7e2bc7b74e989d6b3ffb47bec3
1 file changed
+19
-1
git-count-objects.sh
+19
-1
@@ -1,6 +1,24 @@
1
#!/bin/sh
2
+#
3
+# Copyright (c) 2005 Junio C Hamano
4
+#
5
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
+}
22
23
echo $(find "$GIT_DIR/objects"/?? -type f -print 2>/dev/null | wc -l) objects, \
24
$({