From: Jeff King <peff@peff.net>
To: Matthieu Moy <Matthieu.Moy@imag.fr>
Cc: git@vger.kernel.org
Subject: [PATCH] status: respect advice.statusHints for ahead/behind advice
Date: Mon, 3 Dec 2012 01:16:57 -0500 [thread overview]
Message-ID: <20121203061656.GA20164@sigill.intra.peff.net> (raw)
If the user has unset advice.statusHints, we already
suppress the "use git reset to..." hints in each stanza. The
new "use git push to publish..." hint is the same type of
hint. Let's respect statusHints for it, rather than making
the user set yet another advice flag.
Signed-off-by: Jeff King <peff@peff.net>
---
On top of mm/status-push-pull-advise.
I left "git checkout" alone, though I'd also like to turn it off there,
too. Should it get a separate advice option there? Should it simply
respect statusHints (it seems odd because I know that "status" there
means "git status", not "hints about the status of your repo")?
builtin/checkout.c | 2 +-
remote.c | 17 ++++++++++-------
remote.h | 2 +-
wt-status.c | 2 +-
4 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 781295b..28146d1 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -544,7 +544,7 @@ static void report_tracking(struct branch_info *new)
struct strbuf sb = STRBUF_INIT;
struct branch *branch = branch_get(new->name);
- if (!format_tracking_info(branch, &sb))
+ if (!format_tracking_info(branch, &sb, 1))
return;
fputs(sb.buf, stdout);
strbuf_release(&sb);
diff --git a/remote.c b/remote.c
index 9c19689..176a777 100644
--- a/remote.c
+++ b/remote.c
@@ -1617,7 +1617,7 @@ 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, int advice)
{
int num_ours, num_theirs;
const char *base;
@@ -1633,8 +1633,9 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
"Your branch is ahead of '%s' by %d commits.\n",
num_ours),
base, num_ours);
- strbuf_addf(sb,
- _(" (use \"git push\" to publish your local commits)\n"));
+ if (advice)
+ strbuf_addf(sb,
+ _(" (use \"git push\" to publish your local commits)\n"));
} else if (!num_ours) {
strbuf_addf(sb,
Q_("Your branch is behind '%s' by %d commit, "
@@ -1643,8 +1644,9 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
"and can be fast-forwarded.\n",
num_theirs),
base, num_theirs);
- strbuf_addf(sb,
- _(" (use \"git pull\" to update your local branch)\n"));
+ if (advice)
+ strbuf_addf(sb,
+ _(" (use \"git pull\" to update your local branch)\n"));
} else {
strbuf_addf(sb,
Q_("Your branch and '%s' have diverged,\n"
@@ -1655,8 +1657,9 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
"respectively.\n",
num_theirs),
base, num_ours, num_theirs);
- strbuf_addf(sb,
- _(" (use \"git pull\" to merge the remote branch into yours)\n"));
+ if (advice)
+ strbuf_addf(sb,
+ _(" (use \"git pull\" to merge the remote branch into yours)\n"));
}
return 1;
}
diff --git a/remote.h b/remote.h
index 251d8fd..ac504a5 100644
--- a/remote.h
+++ b/remote.h
@@ -153,7 +153,7 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs);
/* Reporting of tracking info */
int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs);
-int format_tracking_info(struct branch *branch, struct strbuf *sb);
+int format_tracking_info(struct branch *branch, struct strbuf *sb, int advice);
struct ref *get_local_heads(void);
/*
diff --git a/wt-status.c b/wt-status.c
index 2a9658b..b48c8cf 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -755,7 +755,7 @@ static void wt_status_print_tracking(struct wt_status *s)
if (prefixcmp(s->branch, "refs/heads/"))
return;
branch = branch_get(s->branch + 11);
- if (!format_tracking_info(branch, &sb))
+ if (!format_tracking_info(branch, &sb, advice_status_hints))
return;
for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
--
1.7.12.4.42.ge2b5b43
next reply other threads:[~2012-12-03 6:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-03 6:16 Jeff King [this message]
2012-12-03 8:49 ` [PATCH] status: respect advice.statusHints for ahead/behind advice Matthieu Moy
2012-12-03 17:11 ` Junio C Hamano
2012-12-03 18:32 ` Jeff King
2012-12-04 9:17 ` Matthieu Moy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121203061656.GA20164@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Matthieu.Moy@imag.fr \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).