commit - 4d6259f764dcf94a262d688cac3aa166c6085ef4c8f241846d533cb5cc541097
commit + 96dc74b56cfdeb04fe0a4fa12c87ff287fe874f712c90c7e7ed5f460e76f4130
blob - b27807bf1c9d26cb694bb76772e706b3ba32bde10a6995a4d177398c055d4cd9
blob + 11bacdc007a1307a787e5cdfe18cf8b661f45481619336b6991899b5696b2851
--- gotd/repo_write.c
+++ gotd/repo_write.c
size_t len;
struct got_commit_object *commit = NULL;
struct got_tree_object *tree = NULL;
+ struct got_blob_object *blob = NULL;
FILE *outfile = NULL;
memset(&written_resp, 0, sizeof(written_resp));
goto done;
idx = got_packidx_get_object_idx(client->packidx, content_id);
- if (idx == -1)
- goto send_response;
+ if (idx == -1) {
+ /* Fall back on content stored in the repository, if any. */
+ err = got_object_open_as_blob(&blob, repo_write.repo,
+ content_id, 8192, repo_write.diff.fd1 /* XXX */);
+ if (err) {
+ if (err->code == GOT_ERR_NO_OBJ)
+ goto send_response;
+ goto done;
+ }
+ err = got_object_blob_dump_to_file(NULL, NULL, NULL, outfile,
+ blob);
+ if (err)
+ goto done;
+ } else {
+ err = got_packfile_open_object(&obj, &client->pack,
+ client->packidx, idx, content_id);
+ if (err)
+ goto done;
- err = got_packfile_open_object(&obj, &client->pack, client->packidx,
- idx, content_id);
- if (err)
- goto done;
+ if (obj->type != GOT_OBJ_TYPE_BLOB)
+ goto send_response;
- if (obj->type != GOT_OBJ_TYPE_BLOB)
- goto send_response;
-
- err = got_packfile_extract_object(&client->pack, obj, outfile,
- repo_write.base_file, repo_write.accum_file);
- if (err)
- goto done;
+ err = got_packfile_extract_object(&client->pack, obj, outfile,
+ repo_write.base_file, repo_write.accum_file);
+ if (err)
+ goto done;
+ }
written_resp.wrote_content = 1;
send_response:
got_object_commit_close(commit);
if (tree)
got_object_tree_close(tree);
+ if (blob)
+ got_object_blob_close(blob);
return err;
}
blob - c16bcbba5de8b043aec84f895cf16aa67954bf4799919700523e3fc0dbfdc42b
blob + 6b24a4de0ea1ad3eafd1886d5c258db415d9680854309dca7d9334093ce488c6
--- regress/gotsysd/test_gotsysd.sh
+++ regress/gotsysd/test_gotsysd.sh
test_done "$testroot" "$ret"
}
+test_no_gotsys_conf_in_pack() {
+ local testroot=`test_init no_gotsys_conf_in_pack 1`
+
+ got checkout -q $testroot/${GOTSYS_REPO} $testroot/wt >/dev/null
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "got checkout failed unexpectedly" >&2
+ test_done "$testroot" 1
+ return 1
+ fi
+
+ crypted_vm_pw=`echo ${GOTSYSD_VM_PASSWORD} | encrypt | tr -d '\n'`
+ crypted_pw=`echo ${GOTSYSD_DEV_PASSWORD} | encrypt | tr -d '\n'`
+ sshkey=`cat ${GOTSYSD_SSH_PUBKEY}`
+ cat > ${testroot}/wt/gotsys.conf <<EOF
+group slackers
+
+user ${GOTSYSD_TEST_USER} {
+ password "${crypted_vm_pw}"
+ authorized key ${sshkey}
+}
+user ${GOTSYSD_DEV_USER} {
+ password "${crypted_pw}"
+ authorized key ${sshkey}
+}
+repository gotsys.git {
+ permit rw ${GOTSYSD_TEST_USER}
+ permit rw ${GOTSYSD_DEV_USER}
+}
+EOF
+ (cd ${testroot}/wt && got commit -m "set gotsys.conf" \
+ >/dev/null)
+ local commit_id=`git_show_head $testroot/${GOTSYS_REPO}`
+
+ got send -q -i ${GOTSYSD_SSH_KEY} -r ${testroot}/${GOTSYS_REPO}
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "got send failed unexpectedly" >&2
+ test_done "$testroot" 1
+ return 1
+ fi
+
+ # Wait for gotsysd to apply the new configuration.
+ echo "$commit_id" > $testroot/stdout.expected
+ for i in 1 2 3 4 5; do
+ sleep 1
+ ssh -i ${GOTSYSD_SSH_KEY} root@${VMIP} \
+ cat /var/db/gotsysd/commit > $testroot/stdout
+ if cmp -s $testroot/stdout.expected $testroot/stdout; then
+ break;
+ fi
+ done
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "gotsysd failed to apply configuration" >&2
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ # Add an unrelated file and send it. gotd used to error out
+ # when gotsys.conf cannot be found in the uploaded pack file.
+ # But gotsys.conf is legitimately missing because it was not
+ # changed, and sending should succeed.
+ echo "unrelated-file" > $testroot/wt/unrelated-file
+ (cd $testroot/wt && got add unrelated-file > /dev/null)
+ (cd ${testroot}/wt && got commit -m "add an unrelated file" >/dev/null)
+ local commit_id=`git_show_head $testroot/${GOTSYS_REPO}`
+
+ got send -q -i ${GOTSYSD_SSH_KEY} -r ${testroot}/${GOTSYS_REPO}
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "got send failed unexpectedly" >&2
+ test_done "$testroot" 1
+ return 1
+ fi
+
+ # Wait for gotsysd to apply the new configuration.
+ echo "$commit_id" > $testroot/stdout.expected
+ for i in 1 2 3 4 5; do
+ sleep 1
+ ssh -i ${GOTSYSD_SSH_KEY} root@${VMIP} \
+ cat /var/db/gotsysd/commit > $testroot/stdout
+ if cmp -s $testroot/stdout.expected $testroot/stdout; then
+ break;
+ fi
+ done
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "gotsysd failed to apply configuration" >&2
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ test_done "$testroot" "$ret"
+}
+
+
test_parseargs "$@"
run_test test_user_add
run_test test_user_mod
run_test test_http_notification
run_test test_http_notification_hmac
run_test test_email_notification
+run_test test_no_gotsys_conf_in_pack