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

Function wt_shortstatus_print_tracking

wt-status.c:2092–2167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2090}
2091
2092static void wt_shortstatus_print_tracking(struct wt_status *s)
2093{
2094 struct branch *branch;
2095 const char *header_color = color(WT_STATUS_HEADER, s);
2096 const char *branch_color_local = color(WT_STATUS_LOCAL_BRANCH, s);
2097 const char *branch_color_remote = color(WT_STATUS_REMOTE_BRANCH, s);
2098
2099 const char *base;
2100 char *short_base;
2101 const char *branch_name;
2102 int num_ours, num_theirs, sti;
2103 int upstream_is_gone = 0;
2104
2105 color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "## ");
2106
2107 if (!s->branch)
2108 return;
2109 branch_name = s->branch;
2110
2111#define LABEL(string) (s->no_gettext ? (string) : _(string))
2112
2113 if (s->is_initial)
2114 color_fprintf(s->fp, header_color, LABEL(N_("No commits yet on ")));
2115
2116 if (!strcmp(s->branch, "HEAD")) {
2117 color_fprintf(s->fp, color(WT_STATUS_NOBRANCH, s), "%s",
2118 LABEL(N_("HEAD (no branch)")));
2119 goto conclude;
2120 }
2121
2122 skip_prefix(branch_name, "refs/heads/", &branch_name);
2123
2124 branch = branch_get(branch_name);
2125
2126 color_fprintf(s->fp, branch_color_local, "%s", branch_name);
2127
2128 sti = stat_tracking_info(branch, &num_ours, &num_theirs, &base,
2129 0, s->ahead_behind_flags);
2130 if (sti < 0) {
2131 if (!base)
2132 goto conclude;
2133
2134 upstream_is_gone = 1;
2135 }
2136
2137 short_base = refs_shorten_unambiguous_ref(get_main_ref_store(s->repo),
2138 base, 0);
2139 color_fprintf(s->fp, header_color, "...");
2140 color_fprintf(s->fp, branch_color_remote, "%s", short_base);
2141 free(short_base);
2142
2143 if (!upstream_is_gone && !sti)
2144 goto conclude;
2145
2146 color_fprintf(s->fp, header_color, " [");
2147 if (upstream_is_gone) {
2148 color_fprintf(s->fp, header_color, LABEL(N_("gone")));
2149 } else if (s->ahead_behind_flags == AHEAD_BEHIND_QUICK) {

Callers 1

wt_shortstatus_printFunction · 0.85

Calls 6

color_fprintfFunction · 0.85
branch_getFunction · 0.85
stat_tracking_infoFunction · 0.85
get_main_ref_storeFunction · 0.85
colorFunction · 0.70

Tested by

no test coverage detected