path: root/refs.h
diff options
authorNguyễn Thái Ngọc Duy <>2019-03-08 09:28:34 (GMT)
committerJunio C Hamano <>2019-05-15 04:56:43 (GMT)
commit1de16aecf51daf5794aa074f6dd133e088a12690 (patch)
tree08f462da8878ec63fe3cf9a5573da743e767abbf /refs.h
parent7d0c1f4556ad89b2f7eae97d31ea85c3bfdf7c87 (diff)
worktree add: sanitize worktree names
Worktree names are based on $(basename $GIT_WORK_TREE). They aren't significant until 3a3b9d8cde (refs: new ref types to make per-worktree refs visible to all worktrees - 2018-10-21), where worktree name could be part of a refname and must follow refname rules. Update 'worktree add' code to remove special characters to follow these rules. In the future the user will be able to specify the worktree name by themselves if they're not happy with this dumb character substitution. Reported-by: Konstantin Kharlamov <> Helped-by: Jeff King <> Signed-off-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'refs.h')
1 files changed, 6 insertions, 0 deletions
diff --git a/refs.h b/refs.h
index 308fa1f..4d8c546 100644
--- a/refs.h
+++ b/refs.h
@@ -460,6 +460,12 @@ int for_each_reflog(each_ref_fn fn, void *cb_data);
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 *shorten_unambiguous_ref(const char *refname, int strict);