MCPcopy Index your code
hub / github.com/git/git / show_ambiguous_object

Function show_ambiguous_object

object-name.c:293–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291};
292
293static int show_ambiguous_object(const struct object_id *oid, void *data)
294{
295 struct ambiguous_output *state = data;
296 const struct disambiguate_state *ds = state->ds;
297 struct strbuf *advice = &state->advice;
298 struct strbuf *sb = &state->sb;
299 int type;
300 const char *hash;
301
302 if (ds->fn && !ds->fn(ds->repo, oid, ds->cb_data))
303 return 0;
304
305 hash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV);
306 type = odb_read_object_info(ds->repo->objects, oid, NULL);
307
308 if (type < 0) {
309 /*
310 * TRANSLATORS: This is a line of ambiguous object
311 * output shown when we cannot look up or parse the
312 * object in question. E.g. "deadbeef [bad object]".
313 */
314 strbuf_addf(sb, _("%s [bad object]"), hash);
315 goto out;
316 }
317
318 assert(type == OBJ_TREE || type == OBJ_COMMIT ||
319 type == OBJ_BLOB || type == OBJ_TAG);
320
321 if (type == OBJ_COMMIT) {
322 struct strbuf date = STRBUF_INIT;
323 struct strbuf msg = STRBUF_INIT;
324 struct commit *commit = lookup_commit(ds->repo, oid);
325
326 if (commit) {
327 struct pretty_print_context pp = {0};
328 pp.date_mode.type = DATE_SHORT;
329 repo_format_commit_message(the_repository, commit,
330 "%ad", &date, &pp);
331 repo_format_commit_message(the_repository, commit,
332 "%s", &msg, &pp);
333 }
334
335 /*
336 * TRANSLATORS: This is a line of ambiguous commit
337 * object output. E.g.:
338 *
339 * "deadbeef commit 2021-01-01 - Some Commit Message"
340 */
341 strbuf_addf(sb, _("%s commit %s - %s"), hash, date.buf,
342 msg.buf);
343
344 strbuf_release(&date);
345 strbuf_release(&msg);
346 } else if (type == OBJ_TAG) {
347 struct tag *tag = lookup_tag(ds->repo, oid);
348
349 if (!parse_tag(ds->repo, tag) && tag->tag) {
350 /*

Callers

nothing calls this directly

Calls 9

repo_find_unique_abbrevFunction · 0.85
odb_read_object_infoFunction · 0.85
strbuf_addfFunction · 0.85
lookup_commitFunction · 0.85
strbuf_releaseFunction · 0.85
lookup_tagFunction · 0.85
parse_tagFunction · 0.85
show_dateFunction · 0.85

Tested by

no test coverage detected