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

Function show_one_commit

builtin/show-branch.c:306–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306static void show_one_commit(struct commit *commit, int no_name)
307{
308 struct strbuf pretty = STRBUF_INIT;
309 const char *pretty_str = "(unavailable)";
310 struct commit_name *name = commit_to_name(commit);
311
312 if (commit->object.parsed) {
313 pp_commit_easy(CMIT_FMT_ONELINE, commit, &pretty);
314 pretty_str = pretty.buf;
315 }
316 skip_prefix(pretty_str, "[PATCH] ", &pretty_str);
317
318 if (!no_name) {
319 if (name && name->head_name) {
320 printf("[%s", name->head_name);
321 if (name->generation) {
322 if (name->generation == 1)
323 printf("^");
324 else
325 printf("~%d", name->generation);
326 }
327 printf("] ");
328 }
329 else
330 printf("[%s] ",
331 repo_find_unique_abbrev(the_repository, &commit->object.oid,
332 DEFAULT_ABBREV));
333 }
334 puts(pretty_str);
335 strbuf_release(&pretty);
336}
337
338static char *ref_name[MAX_REVS + 1];
339static int ref_name_cnt;

Callers 1

cmd_show_branchFunction · 0.85

Calls 4

commit_to_nameFunction · 0.85
pp_commit_easyFunction · 0.85
repo_find_unique_abbrevFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected