diff options
author | Jeff King <peff@peff.net> | 2015-05-21 00:45:55 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-05-22 09:33:09 -0700 |
commit | 29bc88505f22068d7ee6694240e6b13fddb5d059 (patch) | |
tree | a55a77a4756632a07aa634bc1c1ce7a8f79fb256 /builtin | |
parent | 3dbe9db01bd9c0b0701f72a631ac15b1791f6642 (diff) | |
download | git-29bc88505f22068d7ee6694240e6b13fddb5d059.tar.gz git-29bc88505f22068d7ee6694240e6b13fddb5d059.tar.xz |
for-each-ref: accept "%(push)" format
Just as we have "%(upstream)" to report the "@{upstream}"
for each ref, this patch adds "%(push)" to match "@{push}".
It supports the same tracking format modifiers as upstream
(because you may want to know, for example, which branches
have commits to push).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/for-each-ref.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 2bd19caa9..05dd23d2a 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -74,6 +74,7 @@ static struct { { "contents:body" }, { "contents:signature" }, { "upstream" }, + { "push" }, { "symref" }, { "flag" }, { "HEAD" }, @@ -669,6 +670,16 @@ static void populate_value(struct refinfo *ref) refname = branch_get_upstream(branch, NULL); if (!refname) continue; + } else if (starts_with(name, "push")) { + const char *branch_name; + if (!skip_prefix(ref->refname, "refs/heads/", + &branch_name)) + continue; + branch = branch_get(branch_name); + + refname = branch_get_push(branch, NULL); + if (!refname) + continue; } else if (starts_with(name, "color:")) { char color[COLOR_MAXLEN] = ""; @@ -714,7 +725,8 @@ static void populate_value(struct refinfo *ref) refname = shorten_unambiguous_ref(refname, warn_ambiguous_refs); else if (!strcmp(formatp, "track") && - starts_with(name, "upstream")) { + (starts_with(name, "upstream") || + starts_with(name, "push"))) { char buf[40]; if (stat_tracking_info(branch, &num_ours, @@ -736,7 +748,8 @@ static void populate_value(struct refinfo *ref) } continue; } else if (!strcmp(formatp, "trackshort") && - starts_with(name, "upstream")) { + (starts_with(name, "upstream") || + starts_with(name, "push"))) { assert(branch); if (stat_tracking_info(branch, &num_ours, |