git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Avoid using dc in git-count-objects

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 25, 2005, 23:22 UTC
Message-ID
<Pine.LNX.4.63.0510260120260.28994@wbgn013.biozentrum.uni-wuerzburg.de>

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
Next: Junio C Hamano
Message 1 of 18 in “Avoid using dc in git-count-objects”
  1. Avoid using dc in git-count-objectsJohannes Schindelin, Oct 25, 2005
  2. Junio C HamanoOct 26, 2005
  3. Johannes SchindelinOct 26, 2005
  4. Petr BaudisOct 26, 2005
  5. Matthias UrlichsOct 27, 2005
  6. Johannes SchindelinOct 27, 2005
  7. Linus TorvaldsOct 27, 2005
  8. Junio C HamanoOct 27, 2005
  9. Herbert XuOct 28, 2005
  10. H. Peter AnvinOct 28, 2005
  11. Herbert XuOct 28, 2005
  12. H. Peter AnvinOct 28, 2005
  13. Herbert XuOct 28, 2005
  14. H. Peter AnvinOct 28, 2005
  15. Johannes SchindelinOct 26, 2005
  16. Andreas EricssonOct 26, 2005
  17. Johannes SchindelinOct 26, 2005
  18. Andreas EricssonOct 26, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.