git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob ed33dfa86c2a481f91c8a4f0283e23c6a3bb4974 3024 bytes (raw)
name: promisor-remote.c 	 # note: path name is non-authoritative(*)

  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
 
#include "cache.h"
#include "promisor-remote.h"
#include "config.h"
#include "fetch-object.h"

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

struct promisor_remote *promisor_remote_new(const char *remote_name)
{
	struct promisor_remote *o;

	o = xcalloc(1, sizeof(*o));
	o->remote_name = xstrdup(remote_name);

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

	return o;
}

static struct promisor_remote *promisor_remote_look_up(const char *remote_name,
						       struct promisor_remote **previous)
{
	struct promisor_remote *o, *p;

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

	return NULL;
}

static void promisor_remote_move_to_tail(struct promisor_remote *o,
					 struct promisor_remote *previous)
{
	if (previous)
		previous->next = o->next;
	else
		promisors = o->next ? o->next : o;
	o->next = NULL;
	*promisors_tail = o;
	promisors_tail = &o->next;
}

static int promisor_remote_config(const char *var, const char *value, void *data)
{
	struct promisor_remote *o;
	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_look_up(remote_name, NULL))
			promisor_remote_new(remote_name);

		free(remote_name);
		return 0;
	}
	if (!strcmp(subkey, "partialclonefilter")) {
		char *remote_name = xmemdupz(name, namelen);

		o = promisor_remote_look_up(remote_name, NULL);
		if (!o)
			o = promisor_remote_new(remote_name);

		free(remote_name);
		return git_config_string(&o->partial_clone_filter, var, value);
	}

	return 0;
}

static void promisor_remote_do_init(int force)
{
	static int initialized;

	if (!force && initialized)
		return;
	initialized = 1;

	git_config(promisor_remote_config, NULL);

	if (repository_format_partial_clone) {
		struct promisor_remote *o, *previous;

		o = promisor_remote_look_up(repository_format_partial_clone,
					    &previous);
		if (o)
			promisor_remote_move_to_tail(o, previous);
		else
			promisor_remote_new(repository_format_partial_clone);
	}
}

static inline void promisor_remote_init(void)
{
	promisor_remote_do_init(0);
}

void promisor_remote_reinit(void)
{
	promisor_remote_do_init(1);
}

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

	if (!remote_name)
		return promisors;

	return promisor_remote_look_up(remote_name, NULL);
}

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

int promisor_remote_get_direct(const struct object_id *oids, int oid_nr)
{
	struct promisor_remote *o;

	promisor_remote_init();

	for (o = promisors; o; o = o->next) {
		if (fetch_objects(o->remote_name, oids, oid_nr) < 0)
			continue;
		return 0;
	}

	return -1;
}


debug log:

solving ed33dfa86c ...
found ed33dfa86c in https://public-inbox.org/git/20190312132959.11764-8-chriscool@tuxfamily.org/ ||
	https://public-inbox.org/git/20190122144212.15119-10-chriscool@tuxfamily.org/
found dcf6ef6521 in https://public-inbox.org/git/20190312132959.11764-6-chriscool@tuxfamily.org/ ||
	https://public-inbox.org/git/20190122144212.15119-8-chriscool@tuxfamily.org/
found ea74f6d8a8 in https://public-inbox.org/git/20190312132959.11764-5-chriscool@tuxfamily.org/ ||
	https://public-inbox.org/git/20190122144212.15119-7-chriscool@tuxfamily.org/
found f86f9d0b84 in https://public-inbox.org/git/20190312132959.11764-4-chriscool@tuxfamily.org/ ||
	https://public-inbox.org/git/20190122144212.15119-6-chriscool@tuxfamily.org/
found d2f574651e in https://public-inbox.org/git/20190312132959.11764-3-chriscool@tuxfamily.org/ ||
	https://public-inbox.org/git/20190122144212.15119-5-chriscool@tuxfamily.org/

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

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

skipping https://public-inbox.org/git/20190122144212.15119-5-chriscool@tuxfamily.org/ for d2f574651e
index at:
100644 d2f574651ef1bd61471701b0d3f71b926029f00f	promisor-remote.c

applying [2/5] https://public-inbox.org/git/20190312132959.11764-4-chriscool@tuxfamily.org/
diff --git a/promisor-remote.c b/promisor-remote.c
index d2f574651e..f86f9d0b84 100644

Checking patch promisor-remote.c...
7:32: new blank line at EOF.
+
Applied patch promisor-remote.c cleanly.
warning: 1 line adds whitespace errors.

skipping https://public-inbox.org/git/20190122144212.15119-6-chriscool@tuxfamily.org/ for f86f9d0b84
index at:
100644 f86f9d0b84abc91ad5d47a8a76adda5365f48b3b	promisor-remote.c

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

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

skipping https://public-inbox.org/git/20190122144212.15119-7-chriscool@tuxfamily.org/ for ea74f6d8a8
index at:
100644 ea74f6d8a8336fdc31a64b14e8b8c1c2e15a3a32	promisor-remote.c

applying [4/5] https://public-inbox.org/git/20190312132959.11764-6-chriscool@tuxfamily.org/
diff --git a/promisor-remote.c b/promisor-remote.c
index ea74f6d8a8..dcf6ef6521 100644

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

skipping https://public-inbox.org/git/20190122144212.15119-8-chriscool@tuxfamily.org/ for dcf6ef6521
index at:
100644 dcf6ef65219c72ba71f58e79de7d60661fa034ae	promisor-remote.c

applying [5/5] https://public-inbox.org/git/20190312132959.11764-8-chriscool@tuxfamily.org/
diff --git a/promisor-remote.c b/promisor-remote.c
index dcf6ef6521..ed33dfa86c 100644

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

skipping https://public-inbox.org/git/20190122144212.15119-10-chriscool@tuxfamily.org/ for ed33dfa86c
index at:
100644 ed33dfa86c2a481f91c8a4f0283e23c6a3bb4974	promisor-remote.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).