commit doc: document that -c, -C, -F and --fixup with -m error
[git.git] / checkout.c
blobac42630f7483e8c675c31bb7a0c58262e900b5c3
1 #include "cache.h"
2 #include "remote.h"
3 #include "checkout.h"
5 struct tracking_name_data {
6 /* const */ char *src_ref;
7 char *dst_ref;
8 struct object_id *dst_oid;
9 int unique;
12 static int check_tracking_name(struct remote *remote, void *cb_data)
14 struct tracking_name_data *cb = cb_data;
15 struct refspec query;
16 memset(&query, 0, sizeof(struct refspec));
17 query.src = cb->src_ref;
18 if (remote_find_tracking(remote, &query) ||
19 get_oid(query.dst, cb->dst_oid)) {
20 free(query.dst);
21 return 0;
23 if (cb->dst_ref) {
24 free(query.dst);
25 cb->unique = 0;
26 return 0;
28 cb->dst_ref = query.dst;
29 return 0;
32 const char *unique_tracking_name(const char *name, struct object_id *oid)
34 struct tracking_name_data cb_data = { NULL, NULL, NULL, 1 };
35 cb_data.src_ref = xstrfmt("refs/heads/%s", name);
36 cb_data.dst_oid = oid;
37 for_each_remote(check_tracking_name, &cb_data);
38 free(cb_data.src_ref);
39 if (cb_data.unique)
40 return cb_data.dst_ref;
41 free(cb_data.dst_ref);
42 return NULL;