git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
d1fcd1a8bf0eb890edfcb6f2bf35e364e75d1442 blob 3462 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
 
#include "cache.h"
#include "object-store.h"
#include "promisor-remote.h"
#include "config.h"
#include "fetch-object.h"

static struct promisor_remote *promisors;
static struct promisor_remote **promisors_tail = &promisors;

static struct promisor_remote *promisor_remote_new(const char *remote_name)
{
	struct promisor_remote *r;

	if (*remote_name == '/') {
		warning(_("promisor remote name cannot begin with '/': %s"),
			remote_name);
		return NULL;
	}

	FLEX_ALLOC_STR(r, name, remote_name);

	*promisors_tail = r;
	promisors_tail = &r->next;

	return r;
}

static struct promisor_remote *promisor_remote_lookup(const char *remote_name,
						      struct promisor_remote **previous)
{
	struct promisor_remote *r, *p;

	for (p = NULL, r = promisors; r; p = r, r = r->next)
		if (r->name && !strcmp(r->name, remote_name)) {
			if (previous)
				*previous = p;
			return r;
		}

	return NULL;
}

static int promisor_remote_config(const char *var, const char *value, void *data)
{
	const char *name;
	int namelen;
	const char *subkey;

	if (parse_config_key(var, "remote", &name, &namelen, &subkey) < 0)
		return 0;

	if (!strcmp(subkey, "promisor")) {
		char *remote_name;

		if (!git_config_bool(var, value))
			return 0;

		remote_name = xmemdupz(name, namelen);

		if (!promisor_remote_lookup(remote_name, NULL))
			promisor_remote_new(remote_name);

		free(remote_name);
		return 0;
	}

	return 0;
}

static int initialized;

static void promisor_remote_init(void)
{
	if (initialized)
		return;
	initialized = 1;

	git_config(promisor_remote_config, NULL);
}

static void promisor_remote_clear(void)
{
	while (promisors) {
		struct promisor_remote *r = promisors;
		promisors = promisors->next;
		free(r);
	}

	promisors_tail = &promisors;
}

void promisor_remote_reinit(void)
{
	initialized = 0;
	promisor_remote_clear();
	promisor_remote_init();
}

struct promisor_remote *promisor_remote_find(const char *remote_name)
{
	promisor_remote_init();

	if (!remote_name)
		return promisors;

	return promisor_remote_lookup(remote_name, NULL);
}

int has_promisor_remote(void)
{
	return !!promisor_remote_find(NULL);
}

static int remove_fetched_oids(struct object_id **oids, int oid_nr, int to_free)
{
	int i, missing_nr = 0;
	int *missing = xcalloc(oid_nr, sizeof(*missing));
	struct object_id *old_oids = *oids;
	struct object_id *new_oids;
	int old_fetch_if_missing = fetch_if_missing;

	fetch_if_missing = 0;

	for (i = 0; i < oid_nr; i++)
		if (oid_object_info_extended(the_repository, &old_oids[i], NULL, 0)) {
			missing[i] = 1;
			missing_nr++;
		}

	fetch_if_missing = old_fetch_if_missing;

	if (missing_nr) {
		int j = 0;
		new_oids = xcalloc(missing_nr, sizeof(*new_oids));
		for (i = 0; i < oid_nr; i++)
			if (missing[i])
				oidcpy(&new_oids[j++], &old_oids[i]);
		*oids = new_oids;
		if (to_free)
			free(old_oids);
	}

	return missing_nr;
}

int promisor_remote_get_direct(const struct object_id *oids, int oid_nr)
{
	struct promisor_remote *r;
	struct object_id *missing_oids = (struct object_id *)oids;
	int missing_nr = oid_nr;
	int to_free = 0;
	int res = -1;

	promisor_remote_init();

	for (r = promisors; r; r = r->next) {
		if (fetch_objects(r->name, missing_oids, missing_nr) < 0) {
			if (missing_nr == 1)
				continue;
			missing_nr = remove_fetched_oids(&missing_oids, missing_nr, to_free);
			if (missing_nr) {
				to_free = 1;
				continue;
			}
		}
		res = 0;
		break;
	}

	if (to_free)
		free(missing_oids);

	return res;
}
debug log:

solving d1fcd1a8bf ...
found d1fcd1a8bf in https://public-inbox.org/git/20190401164045.17328-5-chriscool@tuxfamily.org/
found a3d601e45a in https://public-inbox.org/git/20190401164045.17328-4-chriscool@tuxfamily.org/
found 0c768210ee in https://public-inbox.org/git/20190401164045.17328-3-chriscool@tuxfamily.org/

applying [1/3] https://public-inbox.org/git/20190401164045.17328-3-chriscool@tuxfamily.org/
diff --git a/promisor-remote.c b/promisor-remote.c
new file mode 100644
index 0000000000..0c768210ee


applying [2/3] https://public-inbox.org/git/20190401164045.17328-4-chriscool@tuxfamily.org/
diff --git a/promisor-remote.c b/promisor-remote.c
index 0c768210ee..a3d601e45a 100644


applying [3/3] https://public-inbox.org/git/20190401164045.17328-5-chriscool@tuxfamily.org/
diff --git a/promisor-remote.c b/promisor-remote.c
index a3d601e45a..d1fcd1a8bf 100644

Checking patch promisor-remote.c...
Applied patch promisor-remote.c cleanly.
Checking patch promisor-remote.c...
Applied patch promisor-remote.c cleanly.
Checking patch promisor-remote.c...
Applied patch promisor-remote.c cleanly.

index at:
100644 d1fcd1a8bf0eb890edfcb6f2bf35e364e75d1442	promisor-remote.c

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git