From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 4C7FF1F462 for ; Fri, 14 Jun 2019 16:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726276AbfFNQSo (ORCPT ); Fri, 14 Jun 2019 12:18:44 -0400 Received: from cloud.peff.net ([104.130.231.41]:55332 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1725801AbfFNQSn (ORCPT ); Fri, 14 Jun 2019 12:18:43 -0400 Received: (qmail 17451 invoked by uid 109); 14 Jun 2019 16:18:43 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Fri, 14 Jun 2019 16:18:43 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 28393 invoked by uid 111); 14 Jun 2019 16:19:30 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Fri, 14 Jun 2019 12:19:30 -0400 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Fri, 14 Jun 2019 12:18:41 -0400 Date: Fri, 14 Jun 2019 12:18:41 -0400 From: Jeff King To: Emily Shaffer Cc: git@vger.kernel.org Subject: Re: [RFC PATCH] rev-list: clarify --abbrev and --abbrev-commit usage Message-ID: <20190614161841.GB30083@sigill.intra.peff.net> References: <20190613221541.10007-1-emilyshaffer@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190613221541.10007-1-emilyshaffer@google.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Thu, Jun 13, 2019 at 03:15:41PM -0700, Emily Shaffer wrote: > I thought this was odd when I was working on the other rev-list changes > - --abbrev doesn't do anything on its own. It looks like it does work by > itself in other commands, but apparently not in rev-list. > > Listed this patch as RFC because maybe instead it's better to fix > something so --abbrev can be used alone, or teach --abbrev-commit=. > It looks like `git log --abbrev=5` also doesn't work the way one might > expect, which makes sense to me, as they use the same internals for > option parsing (parse_revisions()). > > The manpages for log and rev-list both correctly indicate that > --abbrev= is an optional addition to --abbrev-commit. `git log -h` is > generated by parse-options tooling and doesn't cover --abbrev-commit at > all, but `git rev-list` doesn't use an option parser on its own and the > usage is hardcoded. Yeah, "--abbrev" is a bit tricky here. It is really "when you abbrev, do it to this level". In "log", that means that "git log --abbrev=5 --raw" _does_ do something useful (it abbreviates the blob hashes). And then you may add "--abbrev-commit" on top to ask to abbreviate the commit ids. And rev-list follows that same pattern, except that rev-list _never_ shows diff output. You'd traditionally do (and this is how log was implemented once upon a time): git rev-list HEAD | git diff-tree --stdin --abbrev=5 --raw But even there, we are not seeing the commit id output by rev-list. It goes to diff-tree, which then formats it separately. So if you wanted abbreviated commits there, you'd add "--abbrev-commit" to the diff-tree invocation, not rev-list! So no, I cannot see a way in which "rev-list --abbrev" is useful without "--abbrev-commit". Which means that perhaps the former should imply the latter. And as you noticed in your other patch, there is no way to abbreviate "--objects" output at all. I am not sure I have ever seen a good use for that. Though to be honest, I am not sure that "--abbrev" is really all that useful in the first place. Machine-readable output should never abbreviate, and human-readable ones generally already do. But at any rate, before making any behavior changes it may make sense to think about how they'd interact with "rev-list --objects" abbreviation, if it were to be added. As for the patch itself: > diff --git a/builtin/rev-list.c b/builtin/rev-list.c > index 9f31837d30..6ae0087b01 100644 > --- a/builtin/rev-list.c > +++ b/builtin/rev-list.c > @@ -49,8 +49,8 @@ static const char rev_list_usage[] = > " --objects | --objects-edge\n" > " --unpacked\n" > " --header | --pretty\n" > -" --abbrev= | --no-abbrev\n" > -" --abbrev-commit\n" > +" --abbrev-commit [--abbrev=]\n" > +" --no-abbrev\n" So --no-abbrev clears both --abbrev and --abbrev-commit. That sort of makes sense, though I did not expect it. But it also means that: --abbrev-commit [--abbrev= | --no-abbrev] is not right. Possibly: --abbrev-commit [--abbrev=] | --no-abbrev would show the interaction more clearly, but I don't have a strong opinion. -Peff