{"thread":{"id":"3125","subject":"[PATCH] git-count-objects --all support","startedAt":"2006-01-22T02:27:19Z","lastAt":"2006-01-22T03:48:19Z","messageCount":5,"participants":["Petr Baudis","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"15019","messageId":"20060122022718.16375.78611.stgit@machine.or.cz","threadId":"3125","inReplyTo":null,"subject":"[PATCH] git-count-objects --all support","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-01-22T02:27:19Z","receivedAt":"2006-01-22T02:27:19Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Having command called \"git-count-objects\" count only unpacked objects is\na little strange and confusing. This patch adds a warning if packs are\nalready present in the current repository, an --unpacked argument to\nsuppress the warning, and an --all argument to count even packed objects\n(useful at least for statistics).\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n Documentation/git-count-objects.txt |    9 ++++----\n git-count-objects.sh                |   41 ++++++++++++++++++++++++++++++++---\n 2 files changed, 42 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-count-objects.txt b/Documentation/git-count-objects.txt\nindex 36888d9..105721b 100644\n--- a/Documentation/git-count-objects.txt\n+++ b/Documentation/git-count-objects.txt\n@@ -3,16 +3,17 @@ git-count-objects(1)\n \n NAME\n ----\n-git-count-objects - Reports on unpacked objects.\n+git-count-objects - Reports on objects count.\n \n SYNOPSIS\n --------\n-'git-count-objects'\n+'git-count-objects' [--unpacked | --all]\n \n DESCRIPTION\n -----------\n-This counts the number of unpacked object files and disk space consumed by\n-them, to help you decide when it is a good time to repack.\n+This counts the number of objects and disk space consumed by them.\n+It by default counts only unpacked objects in order to help you decide\n+when it is a good time to repack.\n \n Author\n ------\ndiff --git a/git-count-objects.sh b/git-count-objects.sh\nindex 40c58ef..986ff14 100755\n--- a/git-count-objects.sh\n+++ b/git-count-objects.sh\n@@ -3,7 +3,8 @@\n # Copyright (c) 2005 Junio C Hamano\n #\n \n-GIT_DIR=`git-rev-parse --git-dir` || exit $?\n+USAGE='[--unpacked | --all]'\n+. git-sh-setup\n \n dc </dev/null 2>/dev/null || {\n \t# This is not a real DC at all -- it just knows how\n@@ -20,12 +21,44 @@ dc </dev/null 2>/dev/null || {\n \t}\n }\n \n-echo $(find \"$GIT_DIR/objects\"/?? -type f -print 2>/dev/null | wc -l) objects, \\\n+all= unpacked=\n+while case \"$#\" in 0) break;; esac\n+do\n+  case \"$1\" in\n+  -a|--a|--al|--all)\n+    all=t\n+    shift ;;\n+  -u|--u|--un|--unp|--unpa|--unpac|--unpack|--unpacke|--unpacked)\n+    unpacked=t\n+    shift ;;\n+  *)\n+    usage ;;\n+  esac\n+done\n+\n+has_packs=\n+test -d \"$GIT_DIR/objects/pack\" && test -n \"$(ls \"$GIT_DIR/objects/pack\")\" &&\n+\thas_packs=objects/pack\n+test -n \"$has_packs\" && test -z \"$all\" && test -z \"$unpacked\" &&\n+\techo \"Warning: Ignoring packed objects\"\n+test -z \"$all\" &&\n+\thas_packs=\n+\n+\n+objcount=$(find \"$GIT_DIR/objects\"/?? -type f -print 2>/dev/null | wc -l)\n+test -n \"$has_packs\" && for pack in \"$GIT_DIR/objects/pack\"/*.idx; do\n+\tobjcount=$((objcount+$(git-pack-ls-objects <\"$pack\" 2>/dev/null | wc -l)))\n+done\n+\n+echo $objcount objects, \\\n $({\n     echo 0\n+\n+    cd \"$GIT_DIR\"\n     # \"no-such\" is to help Darwin folks by not using xargs -r.\n-    find \"$GIT_DIR/objects\"/?? -type f -print 2>/dev/null |\n-    xargs du -k \"$GIT_DIR/objects/no-such\" 2>/dev/null |\n+    find objects/?? $has_packs -type f -print 2>/dev/null |\n+    xargs du -k \"objects/no-such\" 2>/dev/null |\n     sed -e 's/[ \t].*/ +/'\n+\n     echo p\n } | dc) kilobytes\n"},{"id":"15022","messageId":"7vslrhht8b.fsf@assigned-by-dhcp.cox.net","threadId":"3125","inReplyTo":"20060122022718.16375.78611.stgit@machine.or.cz","subject":"Re: [PATCH] git-count-objects --all support","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-22T02:49:40Z","receivedAt":"2006-01-22T02:49:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n> Having command called \"git-count-objects\" count only unpacked objects is\n> a little strange and confusing. This patch adds a warning if packs are\n> already present in the current repository,\n\nThe point of counting objects is to see if it is time to repack,\nso the warning is something I am quite hesitant to accept, even\nwith a suppression option.  The other way around is probably OK\n(\"please warn me if I have packs\"), but feels somewhat pointless.\n\nThe --all option might be a welcome addition, though.\n"},{"id":"15024","messageId":"20060122030215.GT28365@pasky.or.cz","threadId":"3125","inReplyTo":"7vslrhht8b.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-count-objects --all support","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-01-22T03:02:15Z","receivedAt":"2006-01-22T03:02:15Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sun, Jan 22, 2006 at 03:49:40AM CET, I got a letter\nwhere Junio C Hamano <junkio@cox.net> said that...\n> Petr Baudis <pasky@suse.cz> writes:\n> \n> > Having command called \"git-count-objects\" count only unpacked objects is\n> > a little strange and confusing. This patch adds a warning if packs are\n> > already present in the current repository,\n> \n> The point of counting objects is to see if it is time to repack,\n> so the warning is something I am quite hesitant to accept, even\n> with a suppression option.\n\nThen please change the command name - it is very confusing this way;\nI've been \"burnt\" (well, no big deal but wrong numbers, but anyway...)\nmultiple times and I know others who were as well.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nOf the 3 great composers Mozart tells us what it's like to be human,\nBeethoven tells us what it's like to be Beethoven and Bach tells us\nwhat it's like to be the universe.  -- Douglas Adams\n"},{"id":"15025","messageId":"7v7j8thsl4.fsf@assigned-by-dhcp.cox.net","threadId":"3125","inReplyTo":"7vslrhht8b.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-count-objects --all support","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-22T03:03:35Z","receivedAt":"2006-01-22T03:03:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> The point of counting objects is to see if it is time to repack,\n> so the warning is something I am quite hesitant to accept, even\n> with a suppression option.  The other way around is probably OK\n> (\"please warn me if I have packs\"), but feels somewhat pointless.\n>\n> The --all option might be a welcome addition, though.\n\nI think your patch counts the same object twice if it is packed\nin more than one packs and/or it has a loose copy _and_ also in\na pack.  If it is a good thing or not is totally up to the\nreason why we are counting.\n\nWe might be better off if we did this kind of additions by\nbuilding on fsck-objects.  For example, you could give a --stat\noption that might say something like this:\n\n\t$ git fsck-objects --full --stat\n        commit\t 2488\n        tree    43343\n        blob   212234\n        total  258065\n\tpacked 184382\n\tloose   78115\n        dups     4432\n\nwhere \"dups\" is number of duplicated copies --- an object packed\nin more than two packs, or appearing in a pack and also having a\nloose copy.  I dunno.\n"},{"id":"15029","messageId":"7vd5ikhqik.fsf@assigned-by-dhcp.cox.net","threadId":"3125","inReplyTo":"20060122030215.GT28365@pasky.or.cz","subject":"Re: [PATCH] git-count-objects --all support","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-22T03:48:19Z","receivedAt":"2006-01-22T03:48:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n>> The point of counting objects is to see if it is time to repack,\n>> so the warning is something I am quite hesitant to accept, even\n>> with a suppression option.\n>\n> Then please change the command name - it is very confusing this way;\n\nTrue.  count-loose-objects would have been a good name, if it\nwere named that way from the beginning.\n"}]}