summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorJeff Hostetler <jeffhost@microsoft.com>2018-01-09 18:50:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-01-24 21:48:39 (GMT)
commitf39a757dd93488103dde76e992a75edf2d772b62 (patch)
treed27d738996d848c0d0e2bababaf4435040fc34f0 /remote.c
parent3ca1897cc1a23f3ad140d759280b73ad7affe696 (diff)
downloadgit-f39a757dd93488103dde76e992a75edf2d772b62.zip
git-f39a757dd93488103dde76e992a75edf2d772b62.tar.gz
git-f39a757dd93488103dde76e992a75edf2d772b62.tar.bz2
status: support --no-ahead-behind in long format
Teach long (normal) status format to respect the --no-ahead-behind parameter and skip the possibly expensive ahead/behind computation between the branch and the upstream. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/remote.c b/remote.c
index e514536..d656e33 100644
--- a/remote.c
+++ b/remote.c
@@ -2096,15 +2096,16 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
/*
* Return true when there is anything to report, otherwise false.
*/
-int format_tracking_info(struct branch *branch, struct strbuf *sb)
+int format_tracking_info(struct branch *branch, struct strbuf *sb,
+ enum ahead_behind_flags abf)
{
- int ours, theirs;
+ int ours, theirs, sti;
const char *full_base;
char *base;
int upstream_is_gone = 0;
- if (stat_tracking_info(branch, &ours, &theirs, &full_base,
- AHEAD_BEHIND_FULL) < 0) {
+ sti = stat_tracking_info(branch, &ours, &theirs, &full_base, abf);
+ if (sti < 0) {
if (!full_base)
return 0;
upstream_is_gone = 1;
@@ -2118,10 +2119,17 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
if (advice_status_hints)
strbuf_addstr(sb,
_(" (use \"git branch --unset-upstream\" to fixup)\n"));
- } else if (!ours && !theirs) {
+ } else if (!sti) {
strbuf_addf(sb,
_("Your branch is up to date with '%s'.\n"),
base);
+ } else if (abf == AHEAD_BEHIND_QUICK) {
+ strbuf_addf(sb,
+ _("Your branch and '%s' refer to different commits.\n"),
+ base);
+ if (advice_status_hints)
+ strbuf_addf(sb, _(" (use \"%s\" for details)\n"),
+ "git status --ahead-behind");
} else if (!theirs) {
strbuf_addf(sb,
Q_("Your branch is ahead of '%s' by %d commit.\n",