356
const struct disambiguate_state *ds = data;
357
struct strbuf desc = STRBUF_INIT;
358
int type;
359
+ const char *hash;
360
361
if (ds->fn && !ds->fn(ds->repo, oid, ds->cb_data))
362
return 0;
363
364
+ hash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV);
365
type = oid_object_info(ds->repo, oid, NULL);
366
367
if (type < 0) {
366
- strbuf_addstr(&desc, "[bad object]");
368
+ /*
369
+ * TRANSLATORS: This is a line of ambiguous object
370
+ * output shown when we cannot look up or parse the
371
+ * object in question. E.g. "deadbeef [bad object]".
372
+ */
373
+ strbuf_addf(&desc, _("%s [bad object]"), hash);
374
goto out;
375
}
376
377
assert(type == OBJ_TREE || type == OBJ_COMMIT ||
378
type == OBJ_BLOB || type == OBJ_TAG);
372
- strbuf_addstr(&desc, type_name(type));
379
380
if (type == OBJ_COMMIT) {
381
+ struct strbuf date = STRBUF_INIT;
382
+ struct strbuf msg = STRBUF_INIT;
383
struct commit *commit = lookup_commit(ds->repo, oid);
384
+
385
if (commit) {
386
struct pretty_print_context pp = {0};
387
pp.date_mode.type = DATE_SHORT;
379
- format_commit_message(commit, " %ad - %s", &desc, &pp);
388
+ format_commit_message(commit, "%ad", &date, &pp);
389
+ format_commit_message(commit, "%s", &msg, &pp);
390
}
391
+
392
+ /*
393
+ * TRANSLATORS: This is a line of ambiguous commit
394
+ * object output. E.g.:
395
+ *
396
+ * "deadbeef commit 2021-01-01 - Some Commit Message"
397
+ */
398
+ strbuf_addf(&desc, _("%s commit %s - %s"),
399
+ hash, date.buf, msg.buf);
400
+
401
+ strbuf_release(&date);
402
+ strbuf_release(&msg);
403
} else if (type == OBJ_TAG) {
404
struct tag *tag = lookup_tag(ds->repo, oid);
383
- if (!parse_tag(tag) && tag->tag)
384
- strbuf_addf(&desc, " %s", tag->tag);
385
- else
386
- strbuf_addstr(&desc, " [tag could not be parsed]");
405
+
406
+ if (!parse_tag(tag) && tag->tag) {
407
+ /*
408
+ * TRANSLATORS: This is a line of ambiguous
409
+ * tag object output. E.g.:
410
+ *
411
+ * "deadbeef tag Some Tag Message"
412
+ *
413
+ * The second argument is the "tag" string
414
+ * from object.c.
415
+ */
416
+ strbuf_addf(&desc, _("%s tag %s"), hash, tag->tag);
417
+ } else {
418
+ /*
419
+ * TRANSLATORS: This is a line of ambiguous
420
+ * tag object output where we couldn't parse
421
+ * the tag itself. E.g.:
422
+ *
423
+ * "deadbeef tag [bad tag, could not parse it]"
424
+ */
425
+ strbuf_addf(&desc, _("%s [bad tag, could not parse it]"),
426
+ hash);
427
+ }
428
+ } else if (type == OBJ_TREE) {
429
+ /*
430
+ * TRANSLATORS: This is a line of ambiguous <type>
431
+ * object output. E.g. "deadbeef tree".
432
+ */
433
+ strbuf_addf(&desc, _("%s tree"), hash);
434
+ } else if (type == OBJ_BLOB) {
435
+ /*
436
+ * TRANSLATORS: This is a line of ambiguous <type>
437
+ * object output. E.g. "deadbeef blob".
438
+ */
439
+ strbuf_addf(&desc, _("%s blob"), hash);
440
}
441
442
+
443
out:
390
- advise(" %s %s",
391
- repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV),
392
- desc.buf);
444
+ /*
445
+ * TRANSLATORS: This is line item of ambiguous object output
446
+ * from describe_ambiguous_object() above. For RTL languages
447
+ * you'll probably want to swap the "%s" and leading " " space
448
+ * around.
449
+ */
450
+ advise(_(" %s"), desc.buf);
451
452
strbuf_release(&desc);
453
return 0;