summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f719259)
raw | patch | inline | side by side (parent: f719259)
author | Linus Torvalds <torvalds@g5.osdl.org> | |
Mon, 4 Jul 2005 20:24:30 +0000 (13:24 -0700) | ||
committer | Linus Torvalds <torvalds@g5.osdl.org> | |
Mon, 4 Jul 2005 20:24:30 +0000 (13:24 -0700) |
It's a generic thing for matching refs from the other side.
cache.h | patch | blob | history | |
connect.c | patch | blob | history | |
send-pack.c | patch | blob | history |
index 52842a0bc2caa318ae9600050e00ad405f2a70fe..c79c70f713b16975c0622eb69d4a172cc73307ba 100644 (file)
--- a/cache.h
+++ b/cache.h
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 60b87f5867eaed8240d943b83dd7a5032ed5f89b..941bf296b0d5a8ded60cea0ed61770dc909d2d88 100644 (file)
--- a/connect.c
+++ b/connect.c
#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 57e88a7637eb9a0976aaef2664c9d2cc06dc07e6..f098acb5fd0510285fa5d4aa63460a57e8183bda 100644 (file)
--- a/send-pack.c
+++ b/send-pack.c
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];