|
13 | 13 | #include "line-log.h"
|
14 | 14 |
|
15 | 15 | static struct decoration name_decoration = { "object names" };
|
| 16 | +static int decoration_loaded; |
| 17 | +static int decoration_flags; |
16 | 18 |
|
17 | 19 | static char decoration_colors[][COLOR_MAXLEN] = {
|
18 | 20 | GIT_COLOR_RESET,
|
@@ -146,9 +148,9 @@ static int add_graft_decoration(const struct commit_graft *graft, void *cb_data)
|
146 | 148 |
|
147 | 149 | void load_ref_decorations(int flags)
|
148 | 150 | {
|
149 |
| - static int loaded; |
150 |
| - if (!loaded) { |
151 |
| - loaded = 1; |
| 151 | + if (!decoration_loaded) { |
| 152 | + decoration_loaded = 1; |
| 153 | + decoration_flags = flags; |
152 | 154 | for_each_ref(add_ref_decoration, &flags);
|
153 | 155 | head_ref(add_ref_decoration, &flags);
|
154 | 156 | for_each_commit_graft(add_graft_decoration, NULL);
|
@@ -196,8 +198,19 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
|
196 | 198 | branch_name = resolve_ref_unsafe("HEAD", 0, unused, &rru_flags);
|
197 | 199 | if (!(rru_flags & REF_ISSYMREF))
|
198 | 200 | return NULL;
|
199 |
| - if (!skip_prefix(branch_name, "refs/heads/", &branch_name)) |
200 |
| - return NULL; |
| 201 | + |
| 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 | + } |
201 | 214 |
|
202 | 215 | /* OK, do we have that ref in the list? */
|
203 | 216 | for (list = decoration; list; list = list->next)
|
|
0 commit comments