5 struct tracking_name_data
{
6 /* const */ char *src_ref
;
8 struct object_id
*dst_oid
;
12 static int check_tracking_name(struct remote
*remote
, void *cb_data
)
14 struct tracking_name_data
*cb
= cb_data
;
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
)) {
28 cb
->dst_ref
= query
.dst
;
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
);
40 return cb_data
.dst_ref
;
41 free(cb_data
.dst_ref
);