GIT_OPT_SET_TEMPLATE_PATH,
GIT_OPT_SET_SSL_CERT_LOCATIONS,
GIT_OPT_SET_USER_AGENT,
+ GIT_OPT_ENABLE_STRICT_OBJECT_CREATION,
} git_libgit2_opt_t;
/**
* > - `user_agent` is the value that will be delivered as the
* > User-Agent header on HTTP requests.
*
+ * * opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, int enabled)
+ *
+ * > Enable strict input validation when creating new objects
+ * > to ensure that all inputs to the new objects are valid. For
+ * > example, when this is enabled, the parent(s) and tree inputs
+ * > will be validated when creating a new commit. This defaults
+ * > to disabled.
+ *
* @param option Option key
* @param ... value to set the option
* @return 0 on success, <0 on failure
#include "blob.h"
#include "tag.h"
+bool git_object__strict_input_validation = false;
+
typedef struct {
const char *str; /* type name string */
size_t size; /* size in bytes of the object structure */
#ifndef INCLUDE_object_h__
#define INCLUDE_object_h__
+extern bool git_object__strict_input_validation;
+
/** Base git object for inheritance */
struct git_object {
git_cached_obj cached;
#include "sysdir.h"
#include "cache.h"
#include "global.h"
+#include "object.h"
void git_libgit2_version(int *major, int *minor, int *rev)
{
}
break;
+
+ case GIT_OPT_ENABLE_STRICT_OBJECT_CREATION:
+ git_object__strict_input_validation = (va_arg(ap, int) != 0);
+ break;
+
default:
giterr_set(GITERR_INVALID, "invalid option key");
error = -1;