diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-04 13:24:30 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-04 13:24:30 -0700 |
commit | 013e7c7ff498aae82d799f80da37fbd395545456 (patch) | |
tree | 25116c39be6efafeba226fb7d04b4fbaa04624d3 /connect.c | |
parent | f71925983ddc365c167559ecc623f2c000607cda (diff) | |
download | git-013e7c7ff498aae82d799f80da37fbd395545456.tar.gz git-013e7c7ff498aae82d799f80da37fbd395545456.tar.xz |
Move ref path matching to connect.c library
It's a generic thing for matching refs from the other side.
Diffstat (limited to 'connect.c')
-rw-r--r-- | connect.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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 |