@@ -94,6 +94,8 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
9494 struct object * obj ;
9595 enum decoration_type type = DECORATION_NONE ;
9696
97+ assert (cb_data == NULL );
98+
9799 if (starts_with (refname , "refs/replace/" )) {
98100 unsigned char original_sha1 [20 ];
99101 if (!check_replace_refs )
@@ -123,8 +125,6 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
123125 else if (!strcmp (refname , "HEAD" ))
124126 type = DECORATION_REF_HEAD ;
125127
126- if (!cb_data || * (int * )cb_data == DECORATE_SHORT_REFS )
127- refname = prettify_refname (refname );
128128 add_name_decoration (type , refname , obj );
129129 while (obj -> type == OBJ_TAG ) {
130130 obj = ((struct tag * )obj )-> tagged ;
@@ -151,8 +151,8 @@ void load_ref_decorations(int flags)
151151 if (!decoration_loaded ) {
152152 decoration_loaded = 1 ;
153153 decoration_flags = flags ;
154- for_each_ref (add_ref_decoration , & flags );
155- head_ref (add_ref_decoration , & flags );
154+ for_each_ref (add_ref_decoration , NULL );
155+ head_ref (add_ref_decoration , NULL );
156156 for_each_commit_graft (add_graft_decoration , NULL );
157157 }
158158}
@@ -199,18 +199,8 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
199199 if (!(rru_flags & REF_ISSYMREF ))
200200 return NULL ;
201201
202- if ((decoration_flags == DECORATE_SHORT_REFS )) {
203- if (!skip_prefix (branch_name , "refs/heads/" , & branch_name ))
204- return NULL ;
205- } else {
206- /*
207- * Each decoration has a refname in full; keep
208- * branch_name also in full, but still make sure
209- * HEAD is a reasonable ref.
210- */
211- if (!starts_with (branch_name , "refs/" ))
212- return NULL ;
213- }
202+ if (!starts_with (branch_name , "refs/" ))
203+ return NULL ;
214204
215205 /* OK, do we have that ref in the list? */
216206 for (list = decoration ; list ; list = list -> next )
@@ -222,6 +212,14 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
222212 return NULL ;
223213}
224214
215+ static void show_name (struct strbuf * sb , const struct name_decoration * decoration )
216+ {
217+ if (decoration_flags == DECORATE_SHORT_REFS )
218+ strbuf_addstr (sb , prettify_refname (decoration -> name ));
219+ else
220+ strbuf_addstr (sb , decoration -> name );
221+ }
222+
225223/*
226224 * The caller makes sure there is no funny color before calling.
227225 * format_decorations_extended makes sure the same after return.
@@ -259,7 +257,7 @@ void format_decorations_extended(struct strbuf *sb,
259257 if (decoration -> type == DECORATION_REF_TAG )
260258 strbuf_addstr (sb , "tag: " );
261259
262- strbuf_addstr (sb , decoration -> name );
260+ show_name (sb , decoration );
263261
264262 if (current_and_HEAD &&
265263 decoration -> type == DECORATION_REF_HEAD ) {
@@ -268,7 +266,7 @@ void format_decorations_extended(struct strbuf *sb,
268266 strbuf_addstr (sb , " -> " );
269267 strbuf_addstr (sb , color_reset );
270268 strbuf_addstr (sb , decorate_get_color (use_color , current_and_HEAD -> type ));
271- strbuf_addstr (sb , current_and_HEAD -> name );
269+ show_name (sb , current_and_HEAD );
272270 }
273271 strbuf_addstr (sb , color_reset );
274272
0 commit comments