6 struct tracking_name_data
{
7 /* const */ char *src_ref
;
9 struct object_id
*dst_oid
;
13 static int check_tracking_name(struct remote
*remote
, void *cb_data
)
15 struct tracking_name_data
*cb
= cb_data
;
16 struct refspec_item query
;
17 memset(&query
, 0, sizeof(struct refspec_item
));
18 query
.src
= cb
->src_ref
;
19 if (remote_find_tracking(remote
, &query
) ||
20 get_oid(query
.dst
, cb
->dst_oid
)) {
29 cb
->dst_ref
= query
.dst
;
33 const char *unique_tracking_name(const char *name
, struct object_id
*oid
)
35 struct tracking_name_data cb_data
= { NULL
, NULL
, NULL
, 1 };
36 cb_data
.src_ref
= xstrfmt("refs/heads/%s", name
);
37 cb_data
.dst_oid
= oid
;
38 for_each_remote(check_tracking_name
, &cb_data
);
39 free(cb_data
.src_ref
);
41 return cb_data
.dst_ref
;
42 free(cb_data
.dst_ref
);