@@ -76,9 +76,11 @@ static struct used_atom {
7676 char color [COLOR_MAXLEN ];
7777 struct align align ;
7878 struct {
79- enum { RR_REF , RR_TRACK , RR_TRACKSHORT } option ;
79+ enum {
80+ RR_REF , RR_TRACK , RR_TRACKSHORT , RR_REMOTE_NAME , RR_REMOTE_REF
81+ } option ;
8082 struct refname_atom refname ;
81- unsigned int nobracket : 1 ;
83+ unsigned int nobracket : 1 , push : 1 , push_remote : 1 ;
8284 } remote_ref ;
8385 struct {
8486 enum { C_BARE , C_BODY , C_BODY_DEP , C_LINES , C_SIG , C_SUB , C_TRAILERS } option ;
@@ -138,6 +140,9 @@ static void remote_ref_atom_parser(const struct ref_format *format, struct used_
138140 struct string_list params = STRING_LIST_INIT_DUP ;
139141 int i ;
140142
143+ if (!strcmp (atom -> name , "push" ) || starts_with (atom -> name , "push:" ))
144+ atom -> u .remote_ref .push = 1 ;
145+
141146 if (!arg ) {
142147 atom -> u .remote_ref .option = RR_REF ;
143148 refname_atom_parser_internal (& atom -> u .remote_ref .refname ,
@@ -157,7 +162,13 @@ static void remote_ref_atom_parser(const struct ref_format *format, struct used_
157162 atom -> u .remote_ref .option = RR_TRACKSHORT ;
158163 else if (!strcmp (s , "nobracket" ))
159164 atom -> u .remote_ref .nobracket = 1 ;
160- else {
165+ else if (!strcmp (s , "remotename" )) {
166+ atom -> u .remote_ref .option = RR_REMOTE_NAME ;
167+ atom -> u .remote_ref .push_remote = 1 ;
168+ } else if (!strcmp (s , "remoteref" )) {
169+ atom -> u .remote_ref .option = RR_REMOTE_REF ;
170+ atom -> u .remote_ref .push_remote = 1 ;
171+ } else {
161172 atom -> u .remote_ref .option = RR_REF ;
162173 refname_atom_parser_internal (& atom -> u .remote_ref .refname ,
163174 arg , atom -> name );
@@ -1268,6 +1279,25 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname,
12681279 * s = ">" ;
12691280 else
12701281 * s = "<>" ;
1282+ } else if (atom -> u .remote_ref .option == RR_REMOTE_NAME ) {
1283+ int explicit ;
1284+ const char * remote = atom -> u .remote_ref .push ?
1285+ pushremote_for_branch (branch , & explicit ) :
1286+ remote_for_branch (branch , & explicit );
1287+ if (explicit )
1288+ * s = xstrdup (remote );
1289+ else
1290+ * s = "" ;
1291+ } else if (atom -> u .remote_ref .option == RR_REMOTE_REF ) {
1292+ int explicit ;
1293+ const char * merge ;
1294+
1295+ merge = remote_ref_for_branch (branch , atom -> u .remote_ref .push ,
1296+ & explicit );
1297+ if (explicit )
1298+ * s = xstrdup (merge );
1299+ else
1300+ * s = "" ;
12711301 } else
12721302 die ("BUG: unhandled RR_* enum" );
12731303}
@@ -1377,16 +1407,20 @@ static void populate_value(struct ref_array_item *ref)
13771407 if (refname )
13781408 fill_remote_ref_details (atom , refname , branch , & v -> s );
13791409 continue ;
1380- } else if (starts_with ( name , " push" ) ) {
1410+ } else if (atom -> u . remote_ref . push ) {
13811411 const char * branch_name ;
13821412 if (!skip_prefix (ref -> refname , "refs/heads/" ,
13831413 & branch_name ))
13841414 continue ;
13851415 branch = branch_get (branch_name );
13861416
1387- refname = branch_get_push (branch , NULL );
1388- if (!refname )
1389- continue ;
1417+ if (atom -> u .remote_ref .push_remote )
1418+ refname = NULL ;
1419+ else {
1420+ refname = branch_get_push (branch , NULL );
1421+ if (!refname )
1422+ continue ;
1423+ }
13901424 fill_remote_ref_details (atom , refname , branch , & v -> s );
13911425 continue ;
13921426 } else if (starts_with (name , "color:" )) {
0 commit comments