Merge branch 'nd/worktree-name-sanitization'
authorJunio C Hamano <gitster@pobox.com>
Thu, 13 Jun 2019 20:19:40 +0000 (13:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Jun 2019 20:19:40 +0000 (13:19 -0700)
In recent versions of Git, per-worktree refs are exposed in
refs/worktrees/<wtname>/ hierarchy, which means that worktree names
must be a valid refname component. The code now sanitizes the names
given to worktrees, to make sure these refs are well-formed.

* nd/worktree-name-sanitization:
worktree add: sanitize worktree names

1  2 
builtin/worktree.c
refs.c
refs.h
Simple merge
diff --cc refs.c
Simple merge
diff --cc refs.h
index 2727405b61c4e26538c3e76b528df37078337376,4d8c5465c33ba7a3c1326d2f5ee7ea1b9f6dab44..730d05ad91a6ac8961c58d599942a5721960d7d7
--- 1/refs.h
--- 2/refs.h
+++ b/refs.h
@@@ -463,10 -460,14 +463,16 @@@ int for_each_reflog(each_ref_fn fn, voi
   */
  int check_refname_format(const char *refname, int flags);
  
+ /*
+  * Apply the rules from check_refname_format, but mutate the result until it
+  * is acceptable, and place the result in "out".
+  */
+ void sanitize_refname_component(const char *refname, struct strbuf *out);
  const char *prettify_refname(const char *refname);
  
 +char *refs_shorten_unambiguous_ref(struct ref_store *refs,
 +                                 const char *refname, int strict);
  char *shorten_unambiguous_ref(const char *refname, int strict);
  
  /** rename ref, return 0 on success **/