git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob ca2b8bf6bbee959725dde6fbbb3e9e32cee7916a 2586 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
 
#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 *do_find_promisor_remote(const char *remote_name)
{
	struct promisor_remote *o;

	for (o = promisors; o; o = o->next)
		if (o->remote_name && !strcmp(o->remote_name, remote_name))
			return o;

	return NULL;
}

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 (do_find_promisor_remote(remote_name)) {
			free(remote_name);
			return error(_("when parsing config key '%s' "
				       "promisor remote '%s' already exists"),
				     var, remote_name);
		}

		promisor_remote_new(remote_name);

		free(remote_name);
		return 0;
	}

	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);
}

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 *find_promisor_remote(const char *remote_name)
{
	promisor_remote_init();

	if (!remote_name)
		return promisors;

	return do_find_promisor_remote(remote_name);
}

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

static int promisor_remote_get_direct(struct promisor_remote *o,
				      const struct object_id *oids,
				      int oid_nr)
{
	int res;
	uint64_t start = getnanotime();

	res = fetch_objects(o->remote_name, oids, oid_nr);

	trace_performance_since(start, "promisor_remote_get_direct");

	return res;
}

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

	trace_printf("trace: promisor_remote_get_direct: nr: %d", oid_nr);

	promisor_remote_init();

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

	return -1;
}


debug log:

solving ca2b8bf6bb ...
found ca2b8bf6bb in https://public-inbox.org/git/20181211052746.16218-5-chriscool@tuxfamily.org/
found e0724bdc20 in https://public-inbox.org/git/20181211052746.16218-4-chriscool@tuxfamily.org/
found 701f5a351b in https://public-inbox.org/git/20181211052746.16218-3-chriscool@tuxfamily.org/

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


applying [2/3] https://public-inbox.org/git/20181211052746.16218-4-chriscool@tuxfamily.org/
diff --git a/promisor-remote.c b/promisor-remote.c
index 701f5a351b..e0724bdc20 100644


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

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

index at:
100644 ca2b8bf6bbee959725dde6fbbb3e9e32cee7916a	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).