aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-04 13:24:30 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-04 13:24:30 -0700
commit013e7c7ff498aae82d799f80da37fbd395545456 (patch)
tree25116c39be6efafeba226fb7d04b4fbaa04624d3
parentf71925983ddc365c167559ecc623f2c000607cda (diff)
downloadgit-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.
-rw-r--r--cache.h1
-rw-r--r--connect.c21
-rw-r--r--send-pack.c21
3 files changed, 22 insertions, 21 deletions
diff --git a/cache.h b/cache.h
index 52842a0bc..c79c70f71 100644
--- a/cache.h
+++ b/cache.h
@@ -261,6 +261,7 @@ struct pack_entry {
extern int git_connect(int fd[2], char *url, const char *prog);
extern int finish_connect(pid_t pid);
+extern int path_match(const char *path, int nr, char **match);
extern void prepare_packed_git(void);
extern int use_packed_git(struct packed_git *);
diff --git a/connect.c b/connect.c
index 60b87f586..941bf296b 100644
--- a/connect.c
+++ b/connect.c
@@ -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
diff --git a/send-pack.c b/send-pack.c
index 57e88a763..f098acb5f 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -4,27 +4,6 @@
static const char send_pack_usage[] = "git-send-pack [--exec=other] destination [heads]*";
static const char *exec = "git-receive-pack";
-static 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;
-}
-
struct ref {
struct ref *next;
unsigned char old_sha1[20];