commit b3b0bea809a80a786998e3d60e67a4cd66ba7619f43fca80ba08e8a2bba1ac60 from: Stefan Sperling date: Wed Oct 14 13:09:00 2026 UTC default to using SHA256 object IDs in newly created repositories Also flip the default for all our test suites to SHA256. Discussed with Thomas Adam for -portable. commit - 331a7a534d021bf36ec8ff2c8b4885f1a51c5951c03ab7b9ea3884cef4f4ef18 commit + b3b0bea809a80a786998e3d60e67a4cd66ba7619f43fca80ba08e8a2bba1ac60 blob - ff474e484925b6a000c7cf805f8facb42ebf16e4d885795b29121b60b5a55302 blob + 996b8cd7a73df085697c3ab809152016f888abc7e21901a412aa3c78fb3b4f9a --- README +++ README @@ -50,12 +50,12 @@ deltified objects, run: $ make regress GOT_TEST_PACK=ref-delta -To test with sha256 object IDs instead of sha1, run: +To test with sha1 object IDs instead of sha256, run: - $ make regress GOT_TEST_ALGO=sha256 + $ make regress GOT_TEST_ALGO=sha1 The GOT_TEST_PACK and GOT_TEST_ALGO flags can be combined to test packed -repositories with sha256 object IDs. +repositories with sha1 object IDs. Because got unveils the /tmp directory by default using the /tmp directory for test data can hide bugs. However, /tmp remains the default because blob - d89a96a47916d3225c54bb2dfeea54e6faf188aaed98bc0c037ee79365e5c88f blob + 72cddd41e46f9025caa134372a9d3bc6426ebc9e17125339fcd7751efc60c6cf --- got/got.1 +++ got/got.1 @@ -113,10 +113,10 @@ Configure the repository's .Ar hashing-algorithm used for the computation of Git object IDs. Possible values are -.Cm sha1 +.Cm sha256 .Pq the default or -.Cm sha256 . +.Cm sha1 . .It Fl b Ar branch Make the repository's HEAD reference point to the specified .Ar branch blob - 4206c40daec04aac080dc80d06c5f9aa048104280629622eddabcc013f188b45 blob + 4265a105da65015306e93815f3b4975d93c9836d85d3c365012f96abc7a66a82 --- got/got.c +++ got/got.c @@ -371,7 +371,7 @@ cmd_init(int argc, char *argv[]) const struct got_error *error = NULL; const char *head_name = NULL; char *repo_path = NULL; - enum got_hash_algorithm algo = GOT_HASH_SHA1; + enum got_hash_algorithm algo = GOT_HASH_SHA256; int ch; while ((ch = getopt(argc, argv, "A:b:")) != -1) { blob - 1b736d93d3dfcf80868e065fb1a297a8aeca8a8e1a2e8c81a35912db33696c20 blob + d51d6bd95f487e822dfb010b00cff73ded563ddf0dcb86be4abf5a18d31723e5 --- gotadmin/gotadmin.1 +++ gotadmin/gotadmin.1 @@ -91,10 +91,10 @@ Configure the repository's .Ar hashing-algorithm used for the computation of Git object IDs. Possible values are -.Cm sha1 +.Cm sha256 .Pq the default or -.Cm sha256 . +.Cm sha1 . .It Fl b Ar branch Make the repository's HEAD reference point to the specified .Ar branch blob - 964a47ff0f217179ad338155c423461c82d0bc70f4287ab054725f344f88e488 blob + 57ba08addc41c1b8ad1852dd300d336798e52d8788e944ea7ebe75dfbc683be4 --- gotadmin/gotadmin.c +++ gotadmin/gotadmin.c @@ -295,7 +295,7 @@ cmd_init(int argc, char *argv[]) const struct got_error *error = NULL; const char *head_name = NULL; char *repo_path = NULL; - enum got_hash_algorithm algo = GOT_HASH_SHA1; + enum got_hash_algorithm algo = GOT_HASH_SHA256; int ch; #ifndef PROFILE blob - 14e54601fef7683d97ad6aecba4f4682a9a53842fa22a448b3890dd848380803 blob + 95eb459ee996c587b6c4ce334956c3762dcab2892338ff4f9571d4ba05ff3bfe --- gotsys/gotsys.conf.5 +++ gotsys/gotsys.conf.5 @@ -295,10 +295,10 @@ Configure the repository's .Ar hashing-algorithm used for the computation of Git object IDs. Possible values are -.Dq sha1 +.Dq sha256 .Pq the default or -.Dq sha256 . +.Dq sha1 . .Pp This configuration directive only affects newly created repositories. The hashing algorithm of existing repositories cannot be changed. blob - 7ceb0a59bddfe52ae4864af5b75a73a2ae01e41727605da621f7c13d91cf90cd blob + 5acba2d735f0c67c032ea7b7eed980307d4e9892f56d1ecaff783f86d3c7c827 --- lib/gotsys_conf.c +++ lib/gotsys_conf.c @@ -908,7 +908,7 @@ gotsys_conf_new_repo(struct gotsys_repo **new_repo, co "repository name too long: %s", name); } - repo->algo = GOT_HASH_SHA1; + repo->algo = GOT_HASH_SHA256; *new_repo = repo; return NULL; blob - ce2c12bcc26caadaab572e3f44886dc596dbe7961b0adf08bdb47938b9922d89 blob + 09831aa5aa9e78af4b633c17418c853cdf8d7464779b6aa36870149d9fdbae56 --- regress/cmdline/common.sh +++ regress/cmdline/common.sh @@ -30,7 +30,7 @@ export GOT_TEST_ROOT="/tmp" export GOT_IGNORE_GITCONFIG=1 export GOT_VERSION_STR=`got --version | cut -d ' ' -f2` export GOT_TEST_HTTP_PORT=${GOT_TEST_HTTP_PORT:-8080} -export GOT_TEST_ALGO="${GOT_TEST_ALGO:-sha1}" +export GOT_TEST_ALGO="${GOT_TEST_ALGO:-sha256}" export LC_ALL=C blob - 528150a732b84f403c17c59c6d7ecf15662bcf176819b696a5507fde96288900 blob + 013e6b0a9ae85f210f432e69f49e5812b8a9431cdc3f1c22c70364e1de1265e1 --- regress/gotd/README +++ regress/gotd/README @@ -57,10 +57,10 @@ The server test suite can now be run from the top-leve The suite must be started as root in order to be able to start and stop gotd. The test suite switches to non-root users as appropriate. -By default the test suite uses repositories with the SHA1 hash algorithm. -The test suite can also be run with SHA256 repositories: +By default the test suite uses repositories with the SHA256 hash algorithm. +The test suite can also be run with SHA1 repositories: - $ doas make server-regress GOT_TEST_ALGO=sha256 + $ doas make server-regress GOT_TEST_ALGO=sha1 The test suite uses netcat on port 2525 to test SMTP notifications. If this port is already in use then affected tests might fail. blob - 82ffff997c4adc36877b804c4f07dc79a325ee93bc7c17641070314c7e05409c blob + 87dc52eca96f98b3e406b14900a5ff6778082beda66a894d6ad19d0ade5ae3af --- regress/gotsysd/README +++ regress/gotsysd/README @@ -54,9 +54,9 @@ Now the actual test suite can be run with: # make -To run the test suite with SHA256 repositories, use: +To run the test suite with SHA1 repositories, use: - # make GOT_TEST_ALGO=sha256 + # make GOT_TEST_ALGO=sha1 A test VM will be started automatically and stopped again once the tests have finished running. blob - 5654ba4d6c2207d00147588040cfce2e51b1289678efc477df7905ec9eb5d949 blob + 5946099a21bcd9dab41a2208add2bbc8b16182df31333b475c59a96981116a40 --- util/got-build-regress.sh +++ util/got-build-regress.sh @@ -164,8 +164,8 @@ if [ "$regress_status" -ne 0 -o "$regress_failure_grep exit 0 fi -printf "\n\n\tRunning tests with sha256\n\n" >> build.log -log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_ALGO=sha256 +printf "\n\n\tRunning tests with sha1\n\n" >> build.log +log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_ALGO=sha1 regress_status="$?" cat regress.log >> build.log egrep "test.*failed" regress.log > failures.log @@ -177,8 +177,8 @@ if [ "$regress_status" -ne 0 -o "$regress_failure_grep exit 0 fi -printf "\n\n\tRunning tests with sha256 and pack files\n\n" >> build.log -log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_ALGO=sha256 GOT_TEST_PACK=1 +printf "\n\n\tRunning tests with sha1 and pack files\n\n" >> build.log +log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_ALGO=sha1 GOT_TEST_PACK=1 regress_status="$?" cat regress.log >> build.log egrep "test.*failed" regress.log > failures.log