Move ref path matching to connect.c library

It's a generic thing for matching refs from the other side.
This commit is contained in:
Linus Torvalds
2005-07-04 13:24:30 -07:00
parent f71925983d
commit 013e7c7ff4
3 changed files with 22 additions and 21 deletions

View File

@ -1,6 +1,27 @@
#include "cache.h"
#include <sys/wait.h>
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