commit - 9edd83064989e03ca1828e9ba7be70381f2e937a3dfa764b2cb29a86173af122
commit + a83ec4e26629480852722012ab506c70bdebce5a2d64527c76bbdba7552655fc
blob - 0d16f56caad2a5c9f16ba5240978a9dfbe78b1cef5cbe3a900a91f70c7650612
blob + 8e337a694a51cf784ebb846929ecda60e92c6adee0794e5a1c15ce0bbbe4327c
--- libexec/got-send-pack/got-send-pack.c
+++ libexec/got-send-pack/got-send-pack.c
if (err)
goto done;
if (is_firstpkt) {
- enum got_hash_algorithm expected_algo = algo;
+ enum got_hash_algorithm server_algo = GOT_HASH_SHA1;
const char *object_format;
if (server_capabilities == NULL) {
capa, ncapa, GOT_CAPA_OBJECT_FORMAT)) {
if (strcmp(object_format,
GOT_CAPA_OBJECT_FORMAT_SHA256) == 0) {
- algo = GOT_HASH_SHA256;
+ server_algo = GOT_HASH_SHA256;
} else if (strcmp(object_format,
GOT_CAPA_OBJECT_FORMAT_SHA1) == 0) {
- algo = GOT_HASH_SHA1;
+ server_algo = GOT_HASH_SHA1;
} else {
err = got_error_fmt(
GOT_ERR_OBJECT_FORMAT,
goto done;
}
}
- if (algo != expected_algo) {
- err = got_error(GOT_ERR_OBJECT_FORMAT);
+
+ if (algo != server_algo) {
+ err = got_error_fmt(GOT_ERR_OBJECT_FORMAT,
+ "the local repository uses %s hashes "
+ "and the remote repository uses %s hashes",
+ got_hash_algo_name(algo),
+ got_hash_algo_name(server_algo));
goto done;
}
blob - 9aa1e5b004ec1f64d13bf1c55ca046df51880e7ad7393d9b3e24ee994228eac4
blob + 275dd3635838ec4e2d2d5874774f702e5d9c779da5204a2e939d3c0cb725e618
--- regress/gotd/repo_write.sh
+++ regress/gotd/repo_write.sh
test_done "$testroot" "$ret"
}
+test_send_incompatible_hash_algo() {
+ local testroot=`test_init send_incompatible_hash_algo 1`
+
+ got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "got clone failed unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ if [ "$GOT_TEST_ALGO" = "sha256" ]; then
+ other_hash=sha1
+ else
+ other_hash=sha256
+ fi
+
+ got init -A $other_hash $testroot/otherhash.git
+
+ mkdir -p $testroot/otherhash
+ echo 'this is file alpha' > $testroot/otherhash/alpha
+ got import -m init -r $testroot/otherhash.git $testroot/otherhash \
+ > /dev/null
+
+ cp $testroot/repo-clone/got.conf $testroot/otherhash.git
+
+ got send -q -r $testroot/otherhash.git \
+ > $testroot/stdout 2> $testroot/stderr
+
+ echo -n "" > $testroot/stdout.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo -n "got-send-pack: " > $testroot/stderr.expected
+ echo -n "the local repository uses $other_hash hashes " \
+ >> $testroot/stderr.expected
+ echo -n "and the remote repository uses ${GOT_TEST_ALGO} hashes: " \
+ >> $testroot/stderr.expected
+ echo "object format not supported" >> $testroot/stderr.expected
+
+ grep '^got-send-pack' $testroot/stderr > $testroot/stderr.filtered
+
+ cmp -s $testroot/stderr.expected $testroot/stderr.filtered
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ fi
+
+ test_done "$testroot" "$ret"
+
+}
+
test_parseargs "$@"
run_test test_send_basic
run_test test_fetch_more_history
run_test test_delete_branch
run_test test_rewind_branch
run_test test_fetch_unrelated_history
+run_test test_send_incompatible_hash_algo