MCPcopy Create free account
hub / github.com/git/git / describe_commit

Function describe_commit

builtin/describe.c:365–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365static 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 }

Callers 2

process_objectFunction · 0.85
describeFunction · 0.85

Calls 15

find_commit_nameFunction · 0.85
append_nameFunction · 0.85
append_suffixFunction · 0.85
get_tagged_oidFunction · 0.85
strbuf_addstrFunction · 0.85
oid_to_hexFunction · 0.85
lazy_queue_putFunction · 0.85
lazy_queue_emptyFunction · 0.85
lazy_queue_getFunction · 0.85
hashmap_get_sizeFunction · 0.85
repo_parse_commitFunction · 0.85

Tested by

no test coverage detected