aboutsummaryrefslogtreecommitdiff
path: root/builtin-branch.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2009-04-07 03:16:56 -0400
committerJunio C Hamano <gitster@pobox.com>2009-04-07 23:22:15 -0700
commit2d8a7f0b30b4f9ef750ab763aabec117ffe4e749 (patch)
tree440dc0e2fb4b139282fa41b0a91e1e06355eb762 /builtin-branch.c
parent7c2b3029df45a74d0ebd11afcc94259791cfb90d (diff)
downloadgit-2d8a7f0b30b4f9ef750ab763aabec117ffe4e749.tar.gz
git-2d8a7f0b30b4f9ef750ab763aabec117ffe4e749.tar.xz
branch: show upstream branch when double verbose
This information is easily accessible when we are calculating the relationship. The only reason not to print it all the time is that it consumes a fair bit of screen space, and may not be of interest to the user. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-branch.c')
-rw-r--r--builtin-branch.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/builtin-branch.c b/builtin-branch.c
index ca81d725c..327582169 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -301,19 +301,30 @@ static int ref_cmp(const void *r1, const void *r2)
return strcmp(c1->name, c2->name);
}
-static void fill_tracking_info(struct strbuf *stat, const char *branch_name)
+static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
+ int show_upstream_ref)
{
int ours, theirs;
struct branch *branch = branch_get(branch_name);
- if (!stat_tracking_info(branch, &ours, &theirs) || (!ours && !theirs))
+ if (!stat_tracking_info(branch, &ours, &theirs)) {
+ if (branch && branch->merge && branch->merge[0]->dst &&
+ show_upstream_ref)
+ strbuf_addf(stat, "[%s] ",
+ shorten_unambiguous_ref(branch->merge[0]->dst));
return;
+ }
+
+ strbuf_addch(stat, '[');
+ if (show_upstream_ref)
+ strbuf_addf(stat, "%s: ",
+ shorten_unambiguous_ref(branch->merge[0]->dst));
if (!ours)
- strbuf_addf(stat, "[behind %d] ", theirs);
+ strbuf_addf(stat, "behind %d] ", theirs);
else if (!theirs)
- strbuf_addf(stat, "[ahead %d] ", ours);
+ strbuf_addf(stat, "ahead %d] ", ours);
else
- strbuf_addf(stat, "[ahead %d, behind %d] ", ours, theirs);
+ strbuf_addf(stat, "ahead %d, behind %d] ", ours, theirs);
}
static int matches_merge_filter(struct commit *commit)
@@ -379,7 +390,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
}
if (item->kind == REF_LOCAL_BRANCH)
- fill_tracking_info(&stat, item->name);
+ fill_tracking_info(&stat, item->name, verbose > 1);
strbuf_addf(&out, " %s %s%s",
find_unique_abbrev(item->commit->object.sha1, abbrev),