Move names_conflict to the common code and make it public. We want to use the same name conflict checks across all backends so we guarantee compatibility across backends. Signed-off-by: Ronnie Sahlberg <sahlberg@xxxxxxxxxx> --- refs-be-files.c | 14 -------------- refs.c | 8 ++++++++ refs.h | 9 +++++++++ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/refs-be-files.c b/refs-be-files.c index 70c034c..6542969 100644 --- a/refs-be-files.c +++ b/refs-be-files.c @@ -676,20 +676,6 @@ static void prime_ref_dir(struct ref_dir *dir) prime_ref_dir(get_ref_dir(entry)); } } -/* - * Return true iff refname1 and refname2 conflict with each other. - * Two reference names conflict if one of them exactly matches the - * leading components of the other; e.g., "foo/bar" conflicts with - * both "foo" and with "foo/bar/baz" but not with "foo/bar" or - * "foo/barbados". - */ -static int names_conflict(const char *refname1, const char *refname2) -{ - for (; *refname1 && *refname1 == *refname2; refname1++, refname2++) - ; - return (*refname1 == '\0' && *refname2 == '/') - || (*refname1 == '/' && *refname2 == '\0'); -} struct name_conflict_cb { const char *refname; diff --git a/refs.c b/refs.c index 9bc0a31..177bed6 100644 --- a/refs.c +++ b/refs.c @@ -688,3 +688,11 @@ int is_branch(const char *refname) { return !strcmp(refname, "HEAD") || starts_with(refname, "refs/heads/"); } + +int names_conflict(const char *refname1, const char *refname2) +{ + for (; *refname1 && *refname1 == *refname2; refname1++, refname2++) + ; + return (*refname1 == '\0' && *refname2 == '/') + || (*refname1 == '/' && *refname2 == '\0'); +} diff --git a/refs.h b/refs.h index d526da0..a14fc5d 100644 --- a/refs.h +++ b/refs.h @@ -128,6 +128,15 @@ int pack_refs(unsigned int flags, struct strbuf *err); extern int ref_exists(const char *); +/* + * Return true iff refname1 and refname2 conflict with each other. + * Two reference names conflict if one of them exactly matches the + * leading components of the other; e.g., "foo/bar" conflicts with + * both "foo" and with "foo/bar/baz" but not with "foo/bar" or + * "foo/barbados". + */ +int names_conflict(const char *refname1, const char *refname2); + extern int is_branch(const char *refname); /* -- 2.0.1.552.g1af257a -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html