| 363 | } |
| 364 | |
| 365 | static void describe_commit(struct commit *cmit, struct strbuf *dst) |
| 366 | { |
| 367 | struct commit *gave_up_on = NULL; |
| 368 | struct lazy_queue queue = LAZY_QUEUE_INIT; |
| 369 | struct commit_name *n; |
| 370 | struct possible_tag all_matches[MAX_TAGS]; |
| 371 | unsigned int match_cnt = 0, annotated_cnt = 0, cur_match; |
| 372 | unsigned long seen_commits = 0; |
| 373 | unsigned int unannotated_cnt = 0; |
| 374 | |
| 375 | n = find_commit_name(&cmit->object.oid); |
| 376 | if (n && (tags || all || n->prio == 2)) { |
| 377 | /* |
| 378 | * Exact match to an existing ref. |
| 379 | */ |
| 380 | append_name(n, dst); |
| 381 | if (n->misnamed || longformat) |
| 382 | append_suffix(0, n->tag ? get_tagged_oid(n->tag) : &cmit->object.oid, dst); |
| 383 | if (suffix) |
| 384 | strbuf_addstr(dst, suffix); |
| 385 | return; |
| 386 | } |
| 387 | |
| 388 | if (!max_candidates) |
| 389 | die(_("no tag exactly matches '%s'"), oid_to_hex(&cmit->object.oid)); |
| 390 | if (debug) |
| 391 | fprintf(stderr, _("No exact match on refs or tags, searching to describe\n")); |
| 392 | |
| 393 | if (!have_util) { |
| 394 | struct hashmap_iter iter; |
| 395 | struct commit *c; |
| 396 | struct commit_name *n; |
| 397 | |
| 398 | init_commit_names(&commit_names); |
| 399 | hashmap_for_each_entry(&names, &iter, n, |
| 400 | entry /* member name */) { |
| 401 | c = lookup_commit_reference_gently(the_repository, |
| 402 | &n->peeled, 1); |
| 403 | if (c) |
| 404 | *commit_names_at(&commit_names, c) = n; |
| 405 | } |
| 406 | have_util = 1; |
| 407 | } |
| 408 | |
| 409 | cmit->object.flags = SEEN; |
| 410 | lazy_queue_put(&queue, cmit); |
| 411 | while (!lazy_queue_empty(&queue)) { |
| 412 | struct commit *c = lazy_queue_get(&queue); |
| 413 | struct commit_list *parents = c->parents; |
| 414 | struct commit_name **slot; |
| 415 | |
| 416 | seen_commits++; |
| 417 | |
| 418 | if (match_cnt == max_candidates || |
| 419 | match_cnt == hashmap_get_size(&names)) { |
| 420 | gave_up_on = c; |
| 421 | break; |
| 422 | } |
no test coverage detected