git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v7 06/11] refname_is_safe(): improve docstring

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Nov 9, 2015, 17:03 UTC
Message-ID
<cffa0c3c8d4f466eedaf6102b783dcef31db4b4d.1447085798.git.mhagger@alum.mit.edu>
In-Reply-To
<cover.1447085798.git.mhagger@alum.mit.edu>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 refs.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/refs.c b/refs.c
index 82129f0..f48c58a 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)
 {
-- 
2.6.2
Previous: Michael HaggertyNext: Michael Haggerty
Message 10 of 18 in “refs backend pre-vtable”
  1. 00/11 refs backend pre-vtableMichael Haggerty, Nov 9, 2015
  2. 01/11 refs: make is_branch publicMichael Haggerty, Nov 9, 2015
  3. Ramsay JonesNov 9, 2015
  4. David TurnerNov 9, 2015
  5. Michael HaggertyNov 10, 2015
  6. 02/11 verify_refname_available(): rename functionMichael Haggerty, Nov 9, 2015
  7. 03/11 verify_refname_available(): new functionMichael Haggerty, Nov 9, 2015
  8. 04/11 copy_msg(): rename to copy_reflog_msg()Michael Haggerty, Nov 9, 2015
  9. 05/11 pack_if_possible_fn(): use ref_type() instead of is_per_worktree_ref()Michael Haggerty, Nov 9, 2015
  10. 06/11 refname_is_safe(): improve docstringMichael Haggerty, Nov 9, 2015
  11. 07/11 refs/refs-internal.h: new header fileMichael Haggerty, Nov 9, 2015
  12. Ramsay JonesNov 9, 2015
  13. David TurnerNov 9, 2015
  14. Michael HaggertyNov 10, 2015
  15. 09/11 initdb: make safe_create_dir publicMichael Haggerty, Nov 9, 2015
  16. 10/11 files_log_ref_write: new functionMichael Haggerty, Nov 9, 2015
  17. 11/11 refs: break out ref conflict checksMichael Haggerty, Nov 9, 2015
  18. David TurnerNov 9, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.