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

Function display_ref_update

builtin/fetch.c:810–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

808}
809
810static void display_ref_update(struct display_state *display_state, char code,
811 const char *summary, const char *error,
812 const char *remote, const char *local,
813 const struct object_id *old_oid,
814 const struct object_id *new_oid,
815 int summary_width)
816{
817 FILE *f = stderr;
818
819 if (verbosity < 0)
820 return;
821
822 strbuf_reset(&display_state->buf);
823
824 switch (display_state->format) {
825 case DISPLAY_FORMAT_FULL:
826 case DISPLAY_FORMAT_COMPACT: {
827 int width;
828
829 if (!display_state->shown_url) {
830 strbuf_addf(&display_state->buf, _("From %.*s\n"),
831 display_state->url_len, display_state->url);
832 display_state->shown_url = 1;
833 }
834
835 width = (summary_width + strlen(summary) - gettext_width(summary));
836 remote = prettify_refname(remote);
837 local = prettify_refname(local);
838
839 strbuf_addf(&display_state->buf, " %c %-*s ", code, width, summary);
840
841 if (display_state->format != DISPLAY_FORMAT_COMPACT)
842 print_remote_to_local(display_state, remote, local);
843 else
844 print_compact(display_state, remote, local);
845
846 if (error)
847 strbuf_addf(&display_state->buf, " (%s)", error);
848
849 break;
850 }
851 case DISPLAY_FORMAT_PORCELAIN:
852 strbuf_addf(&display_state->buf, "%c %s %s %s", code,
853 oid_to_hex(old_oid), oid_to_hex(new_oid), local);
854 f = stdout;
855 break;
856 default:
857 BUG("unexpected display format %d", display_state->format);
858 };
859 strbuf_addch(&display_state->buf, '\n');
860
861 fputs(display_state->buf.buf, f);
862}
863
864struct ref_update_display_info {
865 bool failed;

Callers 2

prune_refsFunction · 0.85

Calls 7

strbuf_addfFunction · 0.85
prettify_refnameFunction · 0.85
print_remote_to_localFunction · 0.85
print_compactFunction · 0.85
oid_to_hexFunction · 0.85
strbuf_addchFunction · 0.85
gettext_widthFunction · 0.50

Tested by

no test coverage detected