From 013e7c7ff498aae82d799f80da37fbd395545456 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 4 Jul 2005 13:24:30 -0700 Subject: Move ref path matching to connect.c library It's a generic thing for matching refs from the other side. --- connect.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'connect.c') diff --git a/connect.c b/connect.c index 60b87f5867..941bf296b0 100644 --- a/connect.c +++ b/connect.c @@ -1,6 +1,27 @@ #include "cache.h" #include +int path_match(const char *path, int nr, char **match) +{ + int i; + int pathlen = strlen(path); + + for (i = 0; i < nr; i++) { + char *s = match[i]; + int len = strlen(s); + + if (!len || len > pathlen) + continue; + if (memcmp(path + pathlen - len, s, len)) + continue; + if (pathlen > len && path[pathlen - len - 1] != '/') + continue; + *s = 0; + return 1; + } + return 0; +} + /* * First, make it shell-safe. We do this by just disallowing any * special characters. Somebody who cares can do escaping and let -- cgit v1.3