Re: [PATCH] Avoid using dc in git-count-objects
Hi,
On Wed, 26 Oct 2005, Johannes Schindelin wrote:
Show 8 quoted lines
> On Tue, 25 Oct 2005, Junio C Hamano wrote:
>
> > Sorry, but I am not very happy about this patch. "local"
> > bashism aside, doesn't this spawn expr for every unpacked
> > object?
>
> Aargh! I had the impression "expr" was a builtin... Just forget about
> the patch, okay?
This patch should be better:
diff --git a/git-count-objects.sh b/git-count-objects.sh
index 843d2fd..ceb1ff2 100755
--- a/git-count-objects.sh
+++ b/git-count-objects.sh
@@ -2,6 +2,19 @@
. git-sh-setup
+case $SHELL in
+*bash)
+ function dc () {
+ while read a b; do
+ case $a,$b in
+ 0,) result=0;;
+ *,+) result=$(($result+$a));;
+ p,) echo $result
+ esac
+ done
+ }
+esac
+
echo $(find "$GIT_DIR/objects"/?? -type f -print 2>/dev/null | wc -l) objects, \
$({
echo 0