Skip to content

Commit c58fc85

Browse files
KarthikNayakgitster
authored andcommitted
ref-filter: include reference to 'used_atom' within 'atom_value'
Ensure that each 'atom_value' has a reference to its corresponding 'used_atom'. This lets us use values within 'used_atom' in the 'handler' function. Hence we can get the %(align) atom's parameters directly from the 'used_atom' therefore removing the necessity of passing %(align) atom's parameters to 'atom_value'. This also acts as a preparatory patch for the upcoming patch where we introduce %(if:equals=) and %(if:notequals=). Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c58492d commit c58fc85

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

ref-filter.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,9 @@ struct ref_formatting_state {
241241

242242
struct atom_value {
243243
const char *s;
244-
union {
245-
struct align align;
246-
} u;
247244
void (*handler)(struct atom_value *atomv, struct ref_formatting_state *state);
248245
unsigned long ul; /* used for sorting when not FIELD_STR */
246+
struct used_atom *atom;
249247
};
250248

251249
/*
@@ -381,7 +379,7 @@ static void align_atom_handler(struct atom_value *atomv, struct ref_formatting_s
381379
push_stack_element(&state->stack);
382380
new = state->stack;
383381
new->at_end = end_align_handler;
384-
new->at_end_data = &atomv->u.align;
382+
new->at_end_data = &atomv->atom->u.align;
385383
}
386384

387385
static void if_then_else_handler(struct ref_formatting_stack **stack)
@@ -1090,6 +1088,7 @@ static void populate_value(struct ref_array_item *ref)
10901088
struct branch *branch = NULL;
10911089

10921090
v->handler = append_atom;
1091+
v->atom = atom;
10931092

10941093
if (*name == '*') {
10951094
deref = 1;
@@ -1154,7 +1153,6 @@ static void populate_value(struct ref_array_item *ref)
11541153
v->s = " ";
11551154
continue;
11561155
} else if (starts_with(name, "align")) {
1157-
v->u.align = atom->u.align;
11581156
v->handler = align_atom_handler;
11591157
continue;
11601158
} else if (!strcmp(name, "end")) {

0 commit comments

Comments
 (0)