From: Jeff Hostetler <git@jeffhostetler.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net,
Jeff Hostetler <jeffhost@microsoft.com>
Subject: [PATCH 2/4] stat_tracking_info: return +1 when branch and upstream differ
Date: Wed, 20 Dec 2017 14:42:43 +0000 [thread overview]
Message-ID: <20171220144245.39401-3-git@jeffhostetler.com> (raw)
In-Reply-To: <20171220144245.39401-1-git@jeffhostetler.com>
From: Jeff Hostetler <jeffhost@microsoft.com>
Extend stat_tracking_info() to return 1 when the branch is
not up to date with its upstream branch and only return 0
when they are equal.
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
ref-filter.c | 4 ++--
remote.c | 6 ++++--
wt-status.c | 2 +-
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/ref-filter.c b/ref-filter.c
index e728b15..10ab4cd 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1239,7 +1239,7 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname,
*s = show_ref(&atom->u.remote_ref.refname, refname);
else if (atom->u.remote_ref.option == RR_TRACK) {
if (stat_tracking_info(branch, &num_ours,
- &num_theirs, NULL)) {
+ &num_theirs, NULL) < 0) {
*s = xstrdup(msgs.gone);
} else if (!num_ours && !num_theirs)
*s = "";
@@ -1257,7 +1257,7 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname,
}
} else if (atom->u.remote_ref.option == RR_TRACKSHORT) {
if (stat_tracking_info(branch, &num_ours,
- &num_theirs, NULL))
+ &num_theirs, NULL) < 0)
return;
if (!num_ours && !num_theirs)
diff --git a/remote.c b/remote.c
index b220f0d..a38b42e 100644
--- a/remote.c
+++ b/remote.c
@@ -1983,7 +1983,9 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
* is not itself NULL.
*
* Returns -1 if num_ours and num_theirs could not be filled in (e.g., no
- * upstream defined, or ref does not exist), 0 otherwise.
+ * upstream defined, or ref does not exist).
+ * Returns 0 if the commits are the same (the branch is up to date).
+ * Returns 1 if the commits are different (the branch is not up to date).
*/
int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
const char **upstream_name)
@@ -2051,7 +2053,7 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
clear_commit_marks(theirs, ALL_REV_FLAGS);
argv_array_clear(&argv);
- return 0;
+ return 1;
}
/*
diff --git a/wt-status.c b/wt-status.c
index 1bc53e1..471ba15 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1935,7 +1935,7 @@ static void wt_porcelain_v2_print_tracking(struct wt_status *s)
base = branch_get_upstream(branch, NULL);
ab_info = 0;
} else {
- ab_info = (stat_tracking_info(branch, &nr_ahead, &nr_behind, &base) == 0);
+ ab_info = (stat_tracking_info(branch, &nr_ahead, &nr_behind, &base) >= 0);
}
if (base) {
--
2.9.3
next prev parent reply other threads:[~2017-12-20 14:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-20 14:42 [PATCH 0/4] Add --no-ahead-behind to status Jeff Hostetler
2017-12-20 14:42 ` [PATCH 1/4] status: add --no-ahead-behind to porcelain V2 Jeff Hostetler
2017-12-20 16:07 ` Jeff King
2017-12-20 16:33 ` Jeff King
2017-12-20 19:44 ` Jeff Hostetler
2017-12-20 14:42 ` Jeff Hostetler [this message]
2017-12-20 16:14 ` [PATCH 2/4] stat_tracking_info: return +1 when branch and upstream differ Jeff King
2017-12-20 16:37 ` Jeff King
2017-12-21 14:06 ` Jeff Hostetler
2017-12-20 14:42 ` [PATCH 3/4] status: update short status to use --no-ahead-behind Jeff Hostetler
2017-12-20 16:26 ` Jeff King
2017-12-21 14:18 ` Jeff Hostetler
2017-12-21 15:39 ` Jeff King
2017-12-21 17:47 ` Jeff Hostetler
2017-12-20 14:42 ` [PATCH 4/4] status: support --no-ahead-behind in long status format Jeff Hostetler
2017-12-20 16:33 ` Jeff King
2017-12-20 16:43 ` [PATCH 0/4] Add --no-ahead-behind to status Jeff King
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=20171220144245.39401-3-git@jeffhostetler.com \
--to=git@jeffhostetler.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jeffhost@microsoft.com \
--cc=peff@peff.net \
/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).