From patchwork Tue Sep 1 07:43:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Wong X-Patchwork-Id: 11747545 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9515E722 for ; Tue, 1 Sep 2020 07:43:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8758B2071B for ; Tue, 1 Sep 2020 07:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726298AbgIAHn4 (ORCPT ); Tue, 1 Sep 2020 03:43:56 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:38662 "EHLO dcvr.yhbt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726124AbgIAHn4 (ORCPT ); Tue, 1 Sep 2020 03:43:56 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C6FCE1F66E; Tue, 1 Sep 2020 07:43:55 +0000 (UTC) Date: Tue, 1 Sep 2020 07:43:55 +0000 From: Eric Wong To: git@vger.kernel.org Cc: "brian m. carlson" Subject: [PATCH] core.abbrev disables abbreviations Message-ID: <20200901074355.GA4498@dcvr> MIME-Version: 1.0 Content-Disposition: inline Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org These allows users to write hash-agnostic scripts and configs to disable abbreviations. Using "-c core.abbrev=40" will be insufficient with SHA-256, and "-c core.abbrev=64" won't work with SHA-1 repos today. Signed-off-by: Eric Wong Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- I kinda wanted to allow a value of "max", but I figured the existing boolean falsiness words might make more sense with `--no-abbrev' in for some commands... Naming is hard :x config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.c b/config.c index 2bdff4457b..f2e09c72ca 100644 --- a/config.c +++ b/config.c @@ -1217,6 +1217,10 @@ static int git_default_core_config(const char *var, const char *value, void *cb) return config_error_nonbool(var); if (!strcasecmp(value, "auto")) default_abbrev = -1; + else if (!strcasecmp(value, "false") || + !strcasecmp(value, "no") || + !strcasecmp(value, "off")) + default_abbrev = the_hash_algo->hexsz; else { int abbrev = git_config_int(var, value); if (abbrev < minimum_abbrev || abbrev > the_hash_algo->hexsz)