git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Avoid using dc in git-count-objects
@ 2005-10-25 23:22 Johannes Schindelin
  2005-10-26  0:12 ` Junio C Hamano
  0 siblings, 1 reply; 18+ messages in thread
From: Johannes Schindelin @ 2005-10-25 23:22 UTC (permalink / raw)
  To: git, junkio

Using dc is not really necessary, since expr understands summing 32 bit 
signed integers. Which means that git-count-objects will now fail when 2 
GB of unpacked objects have accumulated.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

	This is (again) something I found on a default cygwin setup:
	dc is not installed. I do not even know if you can install
	dc on cygwin without compiling it yourself.

	FYI: I use git-count-objects in t5500-fetch-pack to find out
	if the correct number of objects was fetched.

 git-count-objects.sh |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/git-count-objects.sh b/git-count-objects.sh
index 843d2fd..7f9d8e5 100755
--- a/git-count-objects.sh
+++ b/git-count-objects.sh
@@ -2,12 +2,18 @@
 
 . git-sh-setup
 
+function sum () {
+	local result=0
+	while read line; do
+		result=$(expr $result + $line)
+	done
+	echo $result
+}
+
 echo $(find "$GIT_DIR/objects"/?? -type f -print 2>/dev/null | wc -l) objects, \
 $({
-    echo 0
     # "no-such" is to help Darwin folks by not using xargs -r.
     find "$GIT_DIR/objects"/?? -type f -print 2>/dev/null |
     xargs du -k "$GIT_DIR/objects/no-such" 2>/dev/null |
-    sed -e 's/[ 	].*/ +/'
-    echo p
-} | dc) kilobytes
+    sed -e 's/[ 	].*//'
+} | sum) kilobytes

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2005-10-28  5:23 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-25 23:22 [PATCH] Avoid using dc in git-count-objects Johannes Schindelin
2005-10-26  0:12 ` Junio C Hamano
2005-10-26  8:33   ` Johannes Schindelin
2005-10-26  8:36     ` Petr Baudis
2005-10-27  8:50       ` Matthias Urlichs
2005-10-27  9:56         ` Johannes Schindelin
2005-10-27 15:12         ` Linus Torvalds
2005-10-27 18:00           ` Junio C Hamano
2005-10-28  3:20           ` Herbert Xu
2005-10-28  4:14             ` H. Peter Anvin
2005-10-28  4:32               ` Herbert Xu
2005-10-28  4:34                 ` H. Peter Anvin
2005-10-28  4:58                   ` Herbert Xu
2005-10-28  5:22                     ` H. Peter Anvin
2005-10-26  8:58     ` Johannes Schindelin
2005-10-26  9:23   ` Andreas Ericsson
2005-10-26 14:44     ` Johannes Schindelin
2005-10-26 14:55       ` Andreas Ericsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).