summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-11-10 12:42:35 +0100
committerJeff King <peff@peff.net>2015-11-20 04:52:01 -0500
commit03b32623d82d20835d8dda3f9ce9900f09485d11 (patch)
tree524b49ea3f344f11757a28c52805b3125d9730a4 /refs.c
parenta935ebd4a7df505da819371ef10add6ad7bd77d7 (diff)
downloadgit-03b32623d82d20835d8dda3f9ce9900f09485d11.tar.gz
refname_is_safe(): improve docstring
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/refs.c b/refs.c
index 82129f06e2..f48c58a7b6 100644
--- a/refs.c
+++ b/refs.c
@@ -341,13 +341,17 @@ static struct ref_dir *get_ref_dir(struct ref_entry *entry)
}
/*
- * Check if a refname is safe.
- * For refs that start with "refs/" we consider it safe as long they do
- * not try to resolve to outside of refs/.
+ * Return true iff refname is minimally safe. "Safe" here means that
+ * deleting a loose reference by this name will not do any damage, for
+ * example by causing a file that is not a reference to be deleted.
+ * This function does not check that the reference name is legal; for
+ * that, use check_refname_format().
*
- * For all other refs we only consider them safe iff they only contain
- * upper case characters and '_' (like "HEAD" AND "MERGE_HEAD", and not like
- * "config").
+ * We consider a refname that starts with "refs/" to be safe as long
+ * as any ".." components that it might contain do not escape "refs/".
+ * Names that do not start with "refs/" are considered safe iff they
+ * consist entirely of upper case characters and '_' (like "HEAD" and
+ * "MERGE_HEAD" but not "config" or "FOO/BAR").
*/
static int refname_is_safe(const char *refname)
{