diff options
author | Jeff King <peff@peff.net> | 2015-05-21 00:45:28 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-05-21 11:04:42 -0700 |
commit | a9f9f8cc1f59104257eb1a11a2d048f54dd92ee6 (patch) | |
tree | 2d9d48360152e6090d6c6ebf7591017cb7709083 /remote.c | |
parent | 8770e6fbb28dffdf9e00d05365120e438d3d236f (diff) | |
download | git-a9f9f8cc1f59104257eb1a11a2d048f54dd92ee6.tar.gz |
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.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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); |