| 2312 | } |
| 2313 | |
| 2314 | static void format_branch_comparison(struct strbuf *sb, |
| 2315 | bool up_to_date, |
| 2316 | int ours, int theirs, |
| 2317 | const char *branch_name, |
| 2318 | enum ahead_behind_flags abf, |
| 2319 | unsigned flags) |
| 2320 | { |
| 2321 | bool use_push_advice = (flags & ENABLE_ADVICE_PUSH); |
| 2322 | bool use_pull_advice = (flags & ENABLE_ADVICE_PULL); |
| 2323 | bool use_divergence_advice = (flags & ENABLE_ADVICE_DIVERGENCE); |
| 2324 | |
| 2325 | if (up_to_date) { |
| 2326 | strbuf_addf(sb, |
| 2327 | _("Your branch is up to date with '%s'.\n"), |
| 2328 | branch_name); |
| 2329 | } else if (abf == AHEAD_BEHIND_QUICK) { |
| 2330 | strbuf_addf(sb, |
| 2331 | _("Your branch and '%s' refer to different commits.\n"), |
| 2332 | branch_name); |
| 2333 | if (use_push_advice && advice_enabled(ADVICE_STATUS_HINTS)) |
| 2334 | strbuf_addf(sb, _(" (use \"%s\" for details)\n"), |
| 2335 | "git status --ahead-behind"); |
| 2336 | } else if (!theirs) { |
| 2337 | strbuf_addf(sb, |
| 2338 | Q_("Your branch is ahead of '%s' by %d commit.\n", |
| 2339 | "Your branch is ahead of '%s' by %d commits.\n", |
| 2340 | ours), |
| 2341 | branch_name, ours); |
| 2342 | if (use_push_advice && advice_enabled(ADVICE_STATUS_HINTS)) |
| 2343 | strbuf_addstr(sb, |
| 2344 | _(" (use \"git push\" to publish your local commits)\n")); |
| 2345 | } else if (!ours) { |
| 2346 | strbuf_addf(sb, |
| 2347 | Q_("Your branch is behind '%s' by %d commit, " |
| 2348 | "and can be fast-forwarded.\n", |
| 2349 | "Your branch is behind '%s' by %d commits, " |
| 2350 | "and can be fast-forwarded.\n", |
| 2351 | theirs), |
| 2352 | branch_name, theirs); |
| 2353 | if (use_pull_advice && advice_enabled(ADVICE_STATUS_HINTS)) |
| 2354 | strbuf_addstr(sb, |
| 2355 | _(" (use \"git pull\" to update your local branch)\n")); |
| 2356 | } else { |
| 2357 | strbuf_addf(sb, |
| 2358 | Q_("Your branch and '%s' have diverged,\n" |
| 2359 | "and have %d and %d different commit each, " |
| 2360 | "respectively.\n", |
| 2361 | "Your branch and '%s' have diverged,\n" |
| 2362 | "and have %d and %d different commits each, " |
| 2363 | "respectively.\n", |
| 2364 | ours + theirs), |
| 2365 | branch_name, ours, theirs); |
| 2366 | if (use_divergence_advice && advice_enabled(ADVICE_STATUS_HINTS)) |
| 2367 | strbuf_addstr(sb, |
| 2368 | _(" (use \"git pull\" if you want to integrate the remote branch with yours)\n")); |
| 2369 | } |
| 2370 | } |
| 2371 |
no test coverage detected