From 452bf57cbe665768810f2597aba50b9afc9509a7 Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Sat, 27 Aug 2016 13:42:53 +0100 Subject: Make symbolic ref target validation optional Introduce GIT_OPT_ENABLE_SYMBOLIC_REF_TARGET_VALIDATION option. Setting this option to 0 allows validation of a symbolic ref's target to be bypassed. This option is enabled by default. This mechanism is added primarily to address a discrepancy between git behaviour and libgit2 behaviour, whereby the former allows the symbolic ref target to carry an arbitrary string and the latter does not, so: $ git symbolic-ref refs/heads/foo bar $ cat .git/refs/heads/foo ref: bar where as attempting the same via libgit2 raises an error: The given reference name 'bar' is not valid this mechanism also allows those that might want to make use of git's more lenient treatment of symbolic ref targets to do so. --- include/git2/common.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/git2/common.h') diff --git a/include/git2/common.h b/include/git2/common.h index 18abe46b3..02d263048 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -157,6 +157,7 @@ typedef enum { GIT_OPT_SET_SSL_CERT_LOCATIONS, GIT_OPT_SET_USER_AGENT, GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, + GIT_OPT_ENABLE_SYMBOLIC_REF_TARGET_VALIDATION, GIT_OPT_SET_SSL_CIPHERS, GIT_OPT_GET_USER_AGENT, } git_libgit2_opt_t; @@ -270,6 +271,18 @@ typedef enum { * > example, when this is enabled, the parent(s) and tree inputs * > will be validated when creating a new commit. This defaults * > to disabled. + * + * * opts(GIT_OPT_ENABLE_SYMBOLIC_REF_TARGET_VALIDATION, int enabled) + * + * > Validate the target of a symbolic ref when creating it. + * > For example, 'foobar' is not a valid ref, + * > therefore 'foobar' is not a valid target + * > for a symbolic ref by default, + * > where as 'refs/heads/foobar' is. + * > Disabling this bypasses validation so that an arbitrary + * > strings such as 'foobar' can be used for a symbolic ref target. + * > This defaults to enabled. + * * * opts(GIT_OPT_SET_SSL_CIPHERS, const char *ciphers) * * > Set the SSL ciphers use for HTTPS connections. -- cgit v1.2.1 From 28d0ba0ba5f41f71997a15e81bbda4ed2d1b896a Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Sat, 21 Jan 2017 23:45:23 +0000 Subject: symbolic ref target validation: fixups Fixups requested in #3912. --- include/git2/common.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'include/git2/common.h') diff --git a/include/git2/common.h b/include/git2/common.h index 02d263048..3304f46d2 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -157,7 +157,7 @@ typedef enum { GIT_OPT_SET_SSL_CERT_LOCATIONS, GIT_OPT_SET_USER_AGENT, GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, - GIT_OPT_ENABLE_SYMBOLIC_REF_TARGET_VALIDATION, + GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION, GIT_OPT_SET_SSL_CIPHERS, GIT_OPT_GET_USER_AGENT, } git_libgit2_opt_t; @@ -272,16 +272,14 @@ typedef enum { * > will be validated when creating a new commit. This defaults * > to disabled. * - * * opts(GIT_OPT_ENABLE_SYMBOLIC_REF_TARGET_VALIDATION, int enabled) + * * opts(GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION, int enabled) * - * > Validate the target of a symbolic ref when creating it. - * > For example, 'foobar' is not a valid ref, - * > therefore 'foobar' is not a valid target - * > for a symbolic ref by default, - * > where as 'refs/heads/foobar' is. - * > Disabling this bypasses validation so that an arbitrary - * > strings such as 'foobar' can be used for a symbolic ref target. - * > This defaults to enabled. + * > Validate the target of a symbolic ref when creating it. For + * > example, `foobar` is not a valid ref, therefore `foobar` is + * > not a valid target for a symbolic ref by default, whereas + * > `refs/heads/foobar` is. Disabling this bypasses validation + * > so that an arbitrary strings such as `foobar` can be used + * > for a symbolic ref target. This defaults to enabled. * * * opts(GIT_OPT_SET_SSL_CIPHERS, const char *ciphers) * -- cgit v1.2.1