summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-05-21 04:45:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-05-21 18:04:42 (GMT)
commita9f9f8cc1f59104257eb1a11a2d048f54dd92ee6 (patch)
tree2d9d48360152e6090d6c6ebf7591017cb7709083 /remote.c
parent8770e6fbb28dffdf9e00d05365120e438d3d236f (diff)
downloadgit-a9f9f8cc1f59104257eb1a11a2d048f54dd92ee6.zip
git-a9f9f8cc1f59104257eb1a11a2d048f54dd92ee6.tar.gz
git-a9f9f8cc1f59104257eb1a11a2d048f54dd92ee6.tar.bz2
remote.c: introduce branch_get_upstream helper
All of the information needed to find the @{upstream} of a branch is included in the branch struct, but callers have to navigate a series of possible-NULL values to get there. Let's wrap that logic up in an easy-to-read helper. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/remote.c b/remote.c
index e6b29b3..dca3442 100644
--- a/remote.c
+++ b/remote.c
@@ -1705,6 +1705,13 @@ int branch_merge_matches(struct branch *branch,
return refname_match(branch->merge[i]->src, refname);
}
+const char *branch_get_upstream(struct branch *branch)
+{
+ if (!branch || !branch->merge || !branch->merge[0])
+ return NULL;
+ return branch->merge[0]->dst;
+}
+
static int ignore_symref_update(const char *refname)
{
unsigned char sha1[20];
@@ -1914,12 +1921,11 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
int rev_argc;
/* Cannot stat unless we are marked to build on top of somebody else. */
- if (!branch ||
- !branch->merge || !branch->merge[0] || !branch->merge[0]->dst)
+ base = branch_get_upstream(branch);
+ if (!base)
return 0;
/* Cannot stat if what we used to build on no longer exists */
- base = branch->merge[0]->dst;
if (read_ref(base, sha1))
return -1;
theirs = lookup_commit_reference(sha1);