git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob b0c744d37af198d4cbbc0b105d23e15606ebb150 967 bytes (raw)
name: checkout.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
 
#include "cache.h"
#include "remote.h"

struct tracking_name_data {
	/* const */ char *src_ref;
	char *dst_ref;
	struct object_id *dst_oid;
	int unique;
};

static int check_tracking_name(struct remote *remote, void *cb_data)
{
	struct tracking_name_data *cb = cb_data;
	struct refspec query;
	memset(&query, 0, sizeof(struct refspec));
	query.src = cb->src_ref;
	if (remote_find_tracking(remote, &query) ||
	    get_oid(query.dst, cb->dst_oid)) {
		free(query.dst);
		return 0;
	}
	if (cb->dst_ref) {
		free(query.dst);
		cb->unique = 0;
		return 0;
	}
	cb->dst_ref = query.dst;
	return 0;
}

const char *unique_tracking_name(const char *name, struct object_id *oid)
{
	struct tracking_name_data cb_data = { NULL, NULL, NULL, 1 };
	cb_data.src_ref = xstrfmt("refs/heads/%s", name);
	cb_data.dst_oid = oid;
	for_each_remote(check_tracking_name, &cb_data);
	free(cb_data.src_ref);
	if (cb_data.unique)
		return cb_data.dst_ref;
	free(cb_data.dst_ref);
	return NULL;
}

debug log:

solving b0c744d37a ...
found b0c744d37a in https://public-inbox.org/git/20171122223020.2780-2-t.gummerer@gmail.com/ ||
	https://public-inbox.org/git/20171118224706.13810-2-t.gummerer@gmail.com/ ||
	https://public-inbox.org/git/20171118181103.28354-1-t.gummerer@gmail.com/

applying [1/1] https://public-inbox.org/git/20171122223020.2780-2-t.gummerer@gmail.com/
diff --git a/checkout.c b/checkout.c
new file mode 100644
index 0000000000..b0c744d37a

Checking patch checkout.c...
Applied patch checkout.c cleanly.

skipping https://public-inbox.org/git/20171118224706.13810-2-t.gummerer@gmail.com/ for b0c744d37a
skipping https://public-inbox.org/git/20171118181103.28354-1-t.gummerer@gmail.com/ for b0c744d37a
index at:
100644 b0c744d37af198d4cbbc0b105d23e15606ebb150	checkout.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).