commit - 70eab16a09e94ebb211442535cb3329db5577216e3f06467a00f6cb46369c3fd
commit + 0eca45958e84484051dfce1333c59e73de1dd13e1b835b227f8be895cce7e321
blob - c77674a3541b0d028896e8bb0216dfa9776c5f0992bfc8b950506d6db353258c
blob + 1dff288b47b2ab0566b3f581f21411fb8f64760e2820dadb66165f5ca9aad659
--- regress/gotd/Makefile
+++ regress/gotd/Makefile
REGRESS_TARGETS=test_repo_read test_repo_read_group \
test_repo_read_denied_user test_repo_read_denied_group \
test_repo_read_bad_user test_repo_read_bad_group \
- test_repo_write test_repo_write_empty test_request_bad \
+ test_repo_write test_repo_write_empty test_request_bad test_send_bad \
test_repo_write_protected test_repo_write_readonly \
test_email_notification test_http_notification \
test_git_interop test_email_and_http_notification \
'env $(GOTD_TEST_ENV) sh ./request_bad.sh'
@$(GOTD_STOP_CMD) 2>/dev/null
+test_send_bad: prepare_test_repo_empty start_gotd_rw
+ @-$(GOTD_TRAP); su -m ${GOTD_TEST_USER} -c \
+ 'env $(GOTD_TEST_ENV) sh ./send_bad.sh'
+ @$(GOTD_STOP_CMD) 2>/dev/null
+
test_email_notification: prepare_test_repo start_gotd_email_notification
@-$(GOTD_TRAP); su -m ${GOTD_TEST_USER} -c \
'env $(GOTD_TEST_ENV) sh ./email_notification.sh'
blob - /dev/null
blob + efdeb577b1c01a7db395c65f2bf57ad21fd609709f87bf808c1b7358327c1363 (mode 644)
--- /dev/null
+++ regress/gotd/send_bad.sh
+#!/bin/sh
+#
+# Copyright (c) 2026 Stefan Sperling <stsp@openbsd.org>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+. ../cmdline/common.sh
+. ./common.sh
+
+zero_commit="0000000000000000000000000000000000000000"
+basic_capabilities="multi_ack side-band-64k ofs-delta"
+server_capabilities="ofs-delta report-status no-thin delete-refs"
+
+if [ "$GOT_TEST_ALGO" = "sha256" ]; then
+ zero_commit="${zero_commit}000000000000000000000000"
+ capabilities="${basic_capabilities} object-format=sha256"
+ server_capabilities="${server_capabilities} object-format=sha256"
+else
+ capabilities="$basic_capabilities"
+fi
+
+test_send_incompatible_hash_algo() {
+ local testroot=`test_init send_incompatible_hash_algo`
+
+ commit1="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+ commit2="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
+
+ if [ "$GOT_TEST_ALGO" = "sha256" ]; then
+ len="0088"
+ other_algo=sha1
+ capabilities="${basic_capabilities}"
+ else
+ len="00b0"
+ other_algo=sha256
+ my_dummy_commit="${my_dummy_commit}aaaaaaaaaaaaaaaaaaaaaaaa"
+ commit1="${commit1}bbbbbbbbbbbbbbbbbbbbbbbb"
+ commit2="${commit2} object-format=sha256"
+ fi
+
+ # The protocol requires an embedded NUL between reference name
+ # and capabilities.
+ echo -n "${len}$commit1 $commit2 refs/heads/mainX$capabilities" > /tmp/p
+ echo "${len}$commit1 $commit2 refs/heads/mainX$capabilities" | \
+ tr 'X' '\0' | \
+ ssh ${GOTD_DEVUSER}@127.0.0.1 git-receive-pack '/test-repo' \
+ > $testroot/stdout 2>$testroot/stderr
+
+ # Remove embedded NUL from Git protocol with a space character.
+ tr -d '\0' < $testroot/stdout > $testroot/stdout.filtered
+
+ if [ "$GOT_TEST_ALGO" = "sha256" ]; then
+ echo -n "00ae" > $testroot/stdout.expected
+ else
+ echo -n "0081" > $testroot/stdout.expected
+ fi
+ echo -n "$zero_commit capabilities^{} " >> $testroot/stdout.expected
+ echo -n "agent=got/${GOT_VERSION_STR} ${server_capabilities}0000" \
+ >> $testroot/stdout.expected
+
+ if [ "$GOT_TEST_ALGO" = "sha256" ]; then
+ echo -n "009aERR your Git client uses hash algorithm sha1 " \
+ >> $testroot/stdout.expected
+ echo -n "which is incompatible with the hash algorithm " \
+ >> $testroot/stdout.expected
+ echo -n "sha256 used by this repository: " \
+ >> $testroot/stdout.expected
+ echo -n "object format not supported" \
+ >> $testroot/stdout.expected
+
+ echo -n "gotsh: your Git client uses hash algorithm sha1 " \
+ >> $testroot/stderr.expected
+ echo -n "which is incompatible with the hash algorithm " \
+ >> $testroot/stderr.expected
+ echo -n "sha256 used by this repository: " \
+ >> $testroot/stderr.expected
+ echo "object format not supported" \
+ >> $testroot/stderr.expected
+ else
+ echo -n "0025ERR ref-update with bad object ID" \
+ >> $testroot/stdout.expected
+ echo "gotsh: ref-update with bad object ID" \
+ >> $testroot/stderr.expected
+ fi
+
+ cmp -s $testroot/stdout.expected $testroot/stdout.filtered
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "unexpected stdout" >&2
+ diff -a -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "unexpected stderr" >&2
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ test_done "$testroot" "$ret"
+}
+
+run_test test_send_incompatible_hash_algo