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

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 26, 2005, 08:58 UTC
Message-ID
<Pine.LNX.4.63.0510261057560.26001@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<Pine.LNX.4.63.0510261031400.7424@wbgn013.biozentrum.uni-wuerzburg.de>
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
Previous: H. Peter AnvinNext: Andreas Ericsson
Message 15 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.