Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
git-send-pack: add "--all" option to send all refs to the other side
author
Linus Torvalds
<torvalds@g5.osdl.org>
Sat, 16 Jul 2005 20:26:33 +0000
(13:26 -0700)
committer
Linus Torvalds
<torvalds@g5.osdl.org>
Sat, 16 Jul 2005 20:26:33 +0000
(13:26 -0700)
This affects only refs that the other side doesn't already have. The
ones it has are still filtered by the ref selection.
send-pack.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
9c2b1c0
)
diff --git
a/send-pack.c
b/send-pack.c
index 02d1d52c2475759f2b206912bbd626f749a6b750..abc4d1f0007591d8e64792da9098c7042da3bbab 100644
(file)
--- a/
send-pack.c
+++ b/
send-pack.c
@@
-5,6
+5,7
@@
static const char send_pack_usage[] =
"git-send-pack [--exec=git-receive-pack] [host:]directory [heads]*";
static const char *exec = "git-receive-pack";
static const char send_pack_usage[] =
"git-send-pack [--exec=git-receive-pack] [host:]directory [heads]*";
static const char *exec = "git-receive-pack";
+static int send_all = 0;
struct ref {
struct ref *next;
struct ref {
struct ref *next;
@@
-137,15
+138,24
@@
static int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha
static int local_ref_nr_match;
static char **local_ref_match;
static int local_ref_nr_match;
static char **local_ref_match;
-static struct ref **local_ref_list;
+static struct ref *local_ref_list;
+static struct ref **local_last_ref;
static int try_to_match(const char *refname, const unsigned char *sha1)
{
struct ref *ref;
int len;
static int try_to_match(const char *refname, const unsigned char *sha1)
{
struct ref *ref;
int len;
- if (!path_match(refname, local_ref_nr_match, local_ref_match))
- return 0;
+ if (!path_match(refname, local_ref_nr_match, local_ref_match)) {
+ if (!send_all)
+ return 0;
+
+ /* If we have it listed already, skip it */
+ for (ref = local_ref_list ; ref ; ref = ref->next) {
+ if (!strcmp(ref->name, refname))
+ return 0;
+ }
+ }
len = strlen(refname)+1;
ref = xmalloc(sizeof(*ref) + len);
len = strlen(refname)+1;
ref = xmalloc(sizeof(*ref) + len);
@@
-153,8
+163,8
@@
static int try_to_match(const char *refname, const unsigned char *sha1)
memcpy(ref->new_sha1, sha1, 20);
memcpy(ref->name, refname, len);
ref->next = NULL;
memcpy(ref->new_sha1, sha1, 20);
memcpy(ref->name, refname, len);
ref->next = NULL;
- *local_
ref_list
= ref;
- local_
ref_list
= &ref->next;
+ *local_
last_ref
= ref;
+ local_
last_ref
= &ref->next;
return 0;
}
return 0;
}
@@
-225,7
+235,8
@@
static int send_pack(int in, int out, int nr_match, char **match)
if (nr_match) {
local_ref_nr_match = nr_match;
local_ref_match = match;
if (nr_match) {
local_ref_nr_match = nr_match;
local_ref_match = match;
- local_ref_list = last_ref;
+ local_ref_list = ref_list;
+ local_last_ref = last_ref;
for_each_ref(try_to_match);
}
for_each_ref(try_to_match);
}
@@
-260,19
+271,26
@@
int main(int argc, char **argv)
pid_t pid;
argv++;
pid_t pid;
argv++;
- for (i = 1; i < argc; i++) {
- char *arg = *argv
++
;
+ for (i = 1; i < argc; i++
, argv++
) {
+ char *arg = *argv;
if (*arg == '-') {
if (!strncmp(arg, "--exec=", 7)) {
exec = arg + 7;
continue;
}
if (*arg == '-') {
if (!strncmp(arg, "--exec=", 7)) {
exec = arg + 7;
continue;
}
+ if (!strcmp(arg, "--all")) {
+ send_all = 1;
+ continue;
+ }
usage(send_pack_usage);
}
usage(send_pack_usage);
}
- dest = arg;
+ if (!dest) {
+ dest = arg;
+ continue;
+ }
heads = argv;
heads = argv;
- nr_heads = argc - i
-1
;
+ nr_heads = argc - i;
break;
}
if (!dest)
break;
}
if (!dest)