summaryrefslogtreecommitdiff
path: root/refs.h
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-03-08 09:28:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-15 04:56:43 (GMT)
commit1de16aecf51daf5794aa074f6dd133e088a12690 (patch)
tree08f462da8878ec63fe3cf9a5573da743e767abbf /refs.h
parent7d0c1f4556ad89b2f7eae97d31ea85c3bfdf7c87 (diff)
downloadgit-1de16aecf51daf5794aa074f6dd133e088a12690.zip
git-1de16aecf51daf5794aa074f6dd133e088a12690.tar.gz
git-1de16aecf51daf5794aa074f6dd133e088a12690.tar.bz2
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 <hi-angel@yandex.ru> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.h')
-rw-r--r--refs.h6
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);