🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #2632

[PATCH] setup: default hash algo to GIT_HASH_DEFAULT

#2632
From: "brian m. carlson"
Date: Sun, 08 Nov 2026 01:16
53 lines
10366 bytes
When we have no other hash algorithm to choose, we set no hash
algorithm, which ends up with us defaulting to SHA-1.  Instead, default
to GIT_HASH_DEFAULT.  This means that we will choose SHA-256 in breaking
changes mode and in Git 3.0, which is what we want.

Reported-by: Adam Dinwoodie <adam@dinwoodie.org>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 setup.c         |  2 ++
 t/t0001-init.sh | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/setup.c b/setup.c
index 61bcdafe82..4a0dfc8908 100644
--- a/setup.c
+++ b/setup.c
@@ -2830,6 +2830,8 @@ static void repository_format_configure(struct repository_format *repo_fmt,
 			repo_fmt->hash_algo = env_algo;
 	} else if (cfg.hash != GIT_HASH_UNKNOWN) {
 		repo_fmt->hash_algo = cfg.hash;
+	} else {
+		repo_fmt->hash_algo = GIT_HASH_DEFAULT;
 	}
 
 	/*
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index f1d227f271..98c7562f32 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -516,6 +516,22 @@ test_expect_success 're-init from a linked worktree' '
 	)
 '
 
+test_expect_success 'git init uses default object format' '
+	test_when_finished "rm -rf repo" &&
+	(
+		sane_unset GIT_DEFAULT_HASH &&
+		git init repo &&
+		if test_have_prereq WITH_BREAKING_CHANGES
+		then
+			echo sha256
+		else
+			echo sha1
+		fi >expect &&
+		git -C repo rev-parse --show-object-format >actual &&
+		test_cmp expect actual
+	)
+'
+
 test_expect_success 'init honors GIT_DEFAULT_HASH' '
 	test_when_finished "rm -rf sha1 sha256" &&
 	GIT_DEFAULT_HASH=sha1 git init sha1 &&
Technical Details
Message-ID: <20261108011633.1772000-1-sandals@crustytoothpaste.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74812-linux-kernel-git=dewy.ru
References: <CA+kUOampvjU3=VK3VGhYw2L5-E+LBsk=Q0UrAxhhR7hC5SUdJg@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74812-linux-kernel-git=dewy.ru
From: sandals@crustytoothpaste.net ("brian m. carlson")
Newsgroups: linux.kernel.git
Subject: [PATCH] setup: default hash algo to GIT_HASH_DEFAULT
Date: Sun,  8 Nov 2026 01:16:33 +0000
Organization: Usenet Network
Message-ID: <20261108011633.1772000-1-sandals@crustytoothpaste.net>
References: <CA+kUOampvjU3=VK3VGhYw2L5-E+LBsk=Q0UrAxhhR7hC5SUdJg@mail.gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="36572"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:1sb3GoavVYxRU/9VYltggS2m3CI= sha256:MqFql2OoyBHUZwktFGEg/RpIX0SqrxNCZkzacA2Rvgs=
	sha1:cUboYnqS1jcS6OE1MfoMB5mYQWg= sha256:bKvP6nuQqzn5fyNzG8nc8Nh8CCrmn9rQhl1/HItwJPA=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 669AB11338B; Sun,  8 Nov 2026 04:17:13 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (3072-bit key)
	header.d=crustytoothpaste.net
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id rjaeB1fNsnSN;
	Sun,  8 Nov 2026 04:17:06 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74812-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=crustytoothpaste.net
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id F085011078C; Sun,  8 Nov 2026 04:16:55 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id ABFE03DDBD; Sun,  8 Nov 2026 01:16:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794100610;
	b=Hia+VpRHic270EDeRIbEB/T8h2ikmNJt7vQlIbEybcgsm+O6PcENCnOhRXy0WC+GKNmi
	 3LhyQQrPrOgJ6a4VmHArYpCCNGbRjqMeDpwIETfYWJ14z0o7iBqtKQKyDuqE4BFkFbBpp
	 F93zr+fYTgQvGprjJwVjIFVabV/taubtL2IzvXjQs2458NlBUZ7IXhf4JUn8oRMCEwqdk
	 sd9+bBZ2IpSibr/4FbTZq9FvIV42OBKsFEf0urUUIQP6iaH/ZYc6VZQ8aVTvL9EX1kQ+h
	 imDsELHvSyn+jFyg9b3P6fZmq+E6eB772STyaW2VCMrREDbMs0sMIvDElcAgBOu76uw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794100610;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To:
	 Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Bp+tMoHZ54kXst3Shmxegcw/fl38kYxdUUcfi1jjOSY=;
	b=omgD7zWURfcRwb4QieNtt0rK946gKHE3Kh1WfSPb/u5MWCIorNE4h/FW8KQ7nqy/zlmR
	 RX+yIVwfgb5ohrZJDCNtGZGyhfleGJT8dlBmIbNRdyOXRXu8VBwx9ZneutLV7sMdAQyRc
	 w06H65Ev88YIPB8NqDI1DzAx9Cz+Zdli69j0jP1QYDTD9usczm86PTqhsgDYwZptTzWxN
	 m1A2Wka9++ZJuTnktbLEj7aCnmDQA9dzOFKQRVKz5x8+C4Vk3F+nVjmaYtSMQi3bKDlhN
	 awAkbuVVK+XNVCcuIhfQoBlrZ/d8Pwfmlm33CQh0mypksyBUjBglFcLioUls2utfHiA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.a=rsa-sha256 header.s=default header.b=ERGdSnGz;
	dmarc=none header.from=crustytoothpaste.net;
	spf=pass smtp.mailfrom=crustytoothpaste.net;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id EC2F5606A335;
	Sun,  8 Nov 2026 01:16:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (3072-bit key) header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.a=rsa-sha256 header.s=default header.b=ERGdSnGz
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=172.105.7.114
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794100609;
	b=C4AI8IRSDTCLXy/WCwBMT8a/GRzUYBelkL8ck0XF21NNgOhDOpft66lzE/nYr9k2NgQc
	 0SRsoYTnW6dok1U1dC/Sf4eFreTgud5TRFL7pfttPd4t3fToeo8Ky74sOYUuNcLOPocGv
	 mOdyhMB8XjXADUFUIvxxIJXDWeILP69OlzBO0pfwr7K8uR9iWu6nvx8iqOd2nkeOBKaas
	 XjF6rH4U0oB0/3Mak1C2pa5u3wH1TsGNxocBFhMVJLdSRfE/tYQduSSa9tnLszFEJEb0n
	 B/uA6NBaKaID5oh8Ztg8gbcRnvJkezCOdg4mxxTdCaVKOnCvUbLudu0EEF+XiUTu1vQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794100609;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Bp+tMoHZ54kXst3Shmxegcw/fl38kYxdUUcfi1jjOSY=;
	b=2u9nAGXoB44jllPrtZgHsTLpXd9NLEokPTjPq+s/DY4IKBrzM0YjSyV7JqvyoRxLu6gy
	 JPH5LnDVFIvWNbMdbh8b0iThLpellaJwT7LA9LAQmAJ4b+6IckFCr7rDi5TvfgeJwDTAo
	 0edUGRRctUc0uG/KYIw5zitiPqCPhRdz0eRdu5WXD1DHKQ0KiQkSPzNdFBMJLx1iUc5is
	 db3pTfA5AyK3rWoTcbV8zG4GP37qwqO+zY0lCqXv9pfdHxu+eChDmLBWpmj+kxr6tIJii
	 5QAD37Y+2VH4xASs8NiRav73Osm9q6wUlk/bzLN4Av7PHSXJw4KkPefD9xNQNSpaE/g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=crustytoothpaste.net;
	spf=pass smtp.mailfrom=crustytoothpaste.net;
	dkim=pass header.d=crustytoothpaste.net header.i=@crustytoothpaste.net header.a=rsa-sha256 header.s=default header.b=ERGdSnGz;
	arc=none smtp.remote-ip=172.105.7.114
X-Received: from complex.crustytoothpaste.net (complex.crustytoothpaste.net [172.105.7.114])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00B95606A326
	for <git@vger.kernel.org>; Sun,  8 Nov 2026 01:16:47 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 00B95606A326
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=crustytoothpaste.net
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=crustytoothpaste.net
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net;
	s=default; t=1794100600;
	bh=Iz2YK7oEBe2OR9W7zyYWVMkxoTwjYnM/kopVj9Cvvfc=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To:
	 Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc:
	 In-Reply-To:References:Content-Type:Content-Disposition;
	b=ERGdSnGza8vcTioFNIwoqQM+kLUQOc3RIuaOkevxspN7Lk58dE6vHeoVwXHKn1a8S
	 GPF7bGc4kr4aRWAr+rljYGOT7QO3XyCybkbHWXVdWlns5sGZmTUOOK6hOC+Z03Spdv
	 ARSsVyB26atGtSoAlh/D3pla7EkLUk/ncBRDuHIhCUJNXOufw9MgjWvXYYlnlN7LCN
	 DbUDANRqHmVRdLGMX2n3EX2Md0n6QVo6vD1VRDejJuJkEr5IhtYkPk3r3SbcoM4RIO
	 NmgAurXij3HLVd0JTIWszN2N6pYIIAA2sUn4CwzOmya4svDguAxu2awOM4zKppNIVQ
	 VZrDazeWnkH2xYnw78QHvKFwVAdsTJuN6Vk9s0YY936tVC13xzJv7FlAtYHO4TD5GS
	 KO7tUEaRSr3OLe9sXuxom/RMsiSJYZCeaRK/Majjo+Ih/mHXgHBcbHG/VnKhaxbrLf
	 cvIRmyEntQte7OskG+a1P4gPpx6umzVHUeEvBpbSxlfkuix4FZ1
X-Received: from fruit.crustytoothpaste.net (unknown [IPv6:2607:f2c0:f00f:f901:ba43:21ec:77f4:1818])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by complex.crustytoothpaste.net (Postfix) with ESMTPSA id D29B920069;
	Sun,  8 Nov 2026 01:16:40 +0000 (UTC)
X-Cc: Junio C Hamano <gitster@pobox.com>,
	Adam Dinwoodie <adam@dinwoodie.org>
X-Mailer: git-send-email 2.53.0.697.g625c4fb2daa
X-In-Reply-To: <CA+kUOampvjU3=VK3VGhYw2L5-E+LBsk=Q0UrAxhhR7hC5SUdJg@mail.gmail.com>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list