From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-5.5 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 6AC411F4F8 for ; Wed, 5 Oct 2016 18:47:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752897AbcJESrh (ORCPT ); Wed, 5 Oct 2016 14:47:37 -0400 Received: from mout.web.de ([212.227.17.11]:55855 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752257AbcJESrg (ORCPT ); Wed, 5 Oct 2016 14:47:36 -0400 Received: from [192.168.178.36] ([79.213.121.94]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LhNnw-1b5eJm3uam-00mY8M; Wed, 05 Oct 2016 20:47:31 +0200 Subject: Re: [PATCH 16/18] count-objects: report alternates via verbose mode To: Jeff King , git@vger.kernel.org References: <20161003203321.rj5jepviwo57uhqw@sigill.intra.peff.net> <20161003203618.m6kxd3b6h74jbmqz@sigill.intra.peff.net> From: =?UTF-8?Q?Ren=c3=a9_Scharfe?= Message-ID: <5df3d609-62c8-c5e7-d457-76e044ea6438@web.de> Date: Wed, 5 Oct 2016 20:47:27 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <20161003203618.m6kxd3b6h74jbmqz@sigill.intra.peff.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-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gpu8kb9RFz6+Sgl5YNXqL1XoDWoGWn00/y5coasfOz2Qk4g 22e5fIG Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Am 03.10.2016 um 22:36 schrieb Jeff King: > There's no way to get the list of alternates that git > computes internally; our tests only infer it based on which > objects are available. In addition to testing, knowing this > list may be helpful for somebody debugging their alternates > setup. > > Let's add it to the "count-objects -v" output. We could give > it a separate flag, but there's not really any need. > "count-objects -v" is already a debugging catch-all for the > object database, its output is easily extensible to new data > items, and printing the alternates is not expensive (we > already had to find them to count the objects). Good idea. > Signed-off-by: Jeff King > --- > Documentation/git-count-objects.txt | 5 +++++ > builtin/count-objects.c | 10 ++++++++++ > t/t5613-info-alternate.sh | 10 ++++++++++ > 3 files changed, 25 insertions(+) > > diff --git a/Documentation/git-count-objects.txt b/Documentation/git-count-objects.txt > index 2ff3568..cb9b4d2 100644 > --- a/Documentation/git-count-objects.txt > +++ b/Documentation/git-count-objects.txt > @@ -38,6 +38,11 @@ objects nor valid packs > + > size-garbage: disk space consumed by garbage files, in KiB (unless -H is > specified) > ++ > +alternate: absolute path of alternate object databases; may appear > +multiple times, one line per path. Note that if the path contains > +non-printable characters, it may be surrounded by double-quotes and > +contain C-style backslashed escape sequences. > > -H:: > --human-readable:: > diff --git a/builtin/count-objects.c b/builtin/count-objects.c > index ba92919..a700409 100644 > --- a/builtin/count-objects.c > +++ b/builtin/count-objects.c > @@ -8,6 +8,7 @@ > #include "dir.h" > #include "builtin.h" > #include "parse-options.h" > +#include "quote.h" > > static unsigned long garbage; > static off_t size_garbage; > @@ -73,6 +74,14 @@ static int count_cruft(const char *basename, const char *path, void *data) > return 0; > } > > +static int print_alternate(struct alternate_object_database *alt, void *data) > +{ > + printf("alternate: "); > + quote_c_style(alt->path, NULL, stdout, 0); > + putchar('\n'); > + return 0; > +} Yeah, quoting paths makes sense. > + > static char const * const count_objects_usage[] = { > N_("git count-objects [-v] [-H | --human-readable]"), > NULL > @@ -140,6 +149,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix) > printf("prune-packable: %lu\n", packed_loose); > printf("garbage: %lu\n", garbage); > printf("size-garbage: %s\n", garbage_buf.buf); > + foreach_alt_odb(print_alternate, NULL); > strbuf_release(&loose_buf); > strbuf_release(&pack_buf); > strbuf_release(&garbage_buf); > diff --git a/t/t5613-info-alternate.sh b/t/t5613-info-alternate.sh > index b393613..74f6770 100755 > --- a/t/t5613-info-alternate.sh > +++ b/t/t5613-info-alternate.sh > @@ -39,6 +39,16 @@ test_expect_success 'preparing third repository' ' > ) > ' > > +test_expect_success 'count-objects shows the alternates' ' > + cat >expect <<-EOF && > + alternate: $(pwd)/B/.git/objects > + alternate: $(pwd)/A/.git/objects > + EOF > + git -C C count-objects -v >actual && > + grep ^alternate: actual >actual.alternates && > + test_cmp expect actual.alternates > +' > + > # Note: These tests depend on the hard-coded value of 5 as "too deep". We start > # the depth at 0 and count links, not repositories, so in a chain like: > # >