summaryrefslogtreecommitdiff
path: root/receive-pack.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-30 12:28:24 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-30 12:28:24 -0700
commitd0efc8a71da1855c705fd2074b219bcb158b6dbd (patch)
treef26b700095ec30154fede14638a099f49744981d /receive-pack.c
parentf65fdf04a13d2252de8b2b4b161db7c43f2c28ad (diff)
downloadgit-d0efc8a71da1855c705fd2074b219bcb158b6dbd.tar.gz
Do ref matching on the sender side rather than on receiver
This makes the receiver always send a full list of valid refs, which will allow us to do better packs, as well as handle creation of new refs. Eventually. Right now we just moved the matching and enabled it. So now you can do git-send-pack host:path branch1 branch2 to only send branches "branch1" and "branch2".
Diffstat (limited to 'receive-pack.c')
-rw-r--r--receive-pack.c43
1 files changed, 7 insertions, 36 deletions
diff --git a/receive-pack.c b/receive-pack.c
index 0a3e012ade..4019afe1dd 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -2,31 +2,10 @@
#include "pkt-line.h"
#include <sys/wait.h>
-static const char receive_pack_usage[] = "git-receive-pack [--unpack=executable] <git-dir> [heads]";
+static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
static const char *unpacker = "git-unpack-objects";
-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;
-}
-
static void show_ref(const char *path, unsigned char *sha1)
{
packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
@@ -46,7 +25,7 @@ static int read_ref(const char *path, unsigned char *sha1)
return ret;
}
-static void write_head_info(const char *base, int nr, char **match)
+static void write_head_info(const char *base)
{
DIR *dir = opendir(base);
@@ -72,15 +51,13 @@ static void write_head_info(const char *base, int nr, char **match)
if (S_ISDIR(st.st_mode)) {
path[baselen + namelen] = '/';
path[baselen + namelen + 1] = 0;
- write_head_info(path, nr, match);
+ write_head_info(path);
continue;
}
if (read_ref(path, sha1) < 0)
continue;
if (!has_sha1_file(sha1))
continue;
- if (nr && !path_match(path, nr, match))
- continue;
show_ref(path, sha1);
}
free(path);
@@ -247,26 +224,20 @@ static void unpack(void)
int main(int argc, char **argv)
{
- int i, nr_heads = 0;
+ int i;
const char *dir = NULL;
- char **heads = NULL;
argv++;
for (i = 1; i < argc; i++) {
const char *arg = *argv++;
if (*arg == '-') {
- if (!strncmp(arg, "--unpack=", 9)) {
- unpacker = arg+9;
- continue;
- }
/* Do flag handling here */
usage(receive_pack_usage);
}
+ if (dir)
+ usage(receive_pack_usage);
dir = arg;
- heads = argv;
- nr_heads = argc - i - 1;
- break;
}
if (!dir)
usage(receive_pack_usage);
@@ -285,7 +256,7 @@ int main(int argc, char **argv)
if (access("objects", X_OK) < 0 || access("refs/heads", X_OK) < 0)
die("%s doesn't appear to be a git directory", dir);
- write_head_info("refs/", nr_heads, heads);
+ write_head_info("refs/");
/* EOF */
packet_flush(1);