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>
This commit is contained in:

committed by
Junio C Hamano

parent
3dbe9db01b
commit
29bc88505f
@ -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,
|
||||
|
Reference in New Issue
Block a user