status: add advice on how to push/pull to tracking branch
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthieu Moy committed
Nov 15, 2012 at 11:45 UTC
c190ced600223f0774f6ba33f608b1e1347e623e
2 files changed
+11
-3
remote.c
+10
-3
@@ -1627,13 +1627,15 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
1627
1628
base = branch->merge[0]->dst;
1629
base = shorten_unambiguous_ref(base, 0);
1630
- if (!num_theirs)
1630
+ if (!num_theirs) {
1631
strbuf_addf(sb,
1632
Q_("Your branch is ahead of '%s' by %d commit.\n",
1633
"Your branch is ahead of '%s' by %d commits.\n",
1634
num_ours),
1635
base, num_ours);
1636
- else if (!num_ours)
1636
+ strbuf_addf(sb,
1637
+ _(" (use \"git push\" to publish your local commits)\n"));
1638
+ } else if (!num_ours) {
1639
strbuf_addf(sb,
1640
Q_("Your branch is behind '%s' by %d commit, "
1641
"and can be fast-forwarded.\n",
@@ -1641,7 +1643,9 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
1643
"and can be fast-forwarded.\n",
1644
num_theirs),
1645
base, num_theirs);
1644
- else
1646
+ strbuf_addf(sb,
1647
+ _(" (use \"git pull\" to update your local branch)\n"));
1648
+ } else {
1649
strbuf_addf(sb,
1650
Q_("Your branch and '%s' have diverged,\n"
1651
"and have %d and %d different commit each, "
@@ -1651,6 +1655,9 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
1655
"respectively.\n",
1656
num_theirs),
1657
base, num_ours, num_theirs);
1658
+ strbuf_addf(sb,
1659
+ _(" (use \"git pull\" to merge the remote branch into yours)\n"));
1660
+ }
1661
return 1;
1662
}
1663
t/t2020-checkout-detach.sh
+1
@@ -151,6 +151,7 @@ test_expect_success 'checkout does not warn leaving reachable commit' '
151
152
cat >expect <<'EOF'
153
Your branch is behind 'master' by 1 commit, and can be fast-forwarded.
154
+ (use "git pull" to update your local branch)
155
EOF
156
test_expect_success 'tracking count is accurate after orphan check' '
157
reset &&