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 <Karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Karthik Nayak committed
Jan 10, 2017 at 14:19 UTC
c58fc85692d759cb33a59e138a94931044a08284
1 file changed
+3
-5
ref-filter.c
+3
-5
@@ -241,11 +241,9 @@ struct ref_formatting_state {
241
242
struct atom_value {
243
const char *s;
244
- union {
245
- struct align align;
246
- } u;
244
void (*handler)(struct atom_value *atomv, struct ref_formatting_state *state);
245
unsigned long ul; /* used for sorting when not FIELD_STR */
246
+ struct used_atom *atom;
247
};
248
249
/*
@@ -381,7 +379,7 @@ static void align_atom_handler(struct atom_value *atomv, struct ref_formatting_s
379
push_stack_element(&state->stack);
380
new = state->stack;
381
new->at_end = end_align_handler;
384
- new->at_end_data = &atomv->u.align;
382
+ new->at_end_data = &atomv->atom->u.align;
383
}
384
385
static void if_then_else_handler(struct ref_formatting_stack **stack)
@@ -1090,6 +1088,7 @@ static void populate_value(struct ref_array_item *ref)
1088
struct branch *branch = NULL;
1089
1090
v->handler = append_atom;
1091
+ v->atom = atom;
1092
1093
if (*name == '*') {
1094
deref = 1;
@@ -1154,7 +1153,6 @@ static void populate_value(struct ref_array_item *ref)
1153
v->s = " ";
1154
continue;
1155
} else if (starts_with(name, "align")) {
1157
- v->u.align = atom->u.align;
1156
v->handler = align_atom_handler;
1157
continue;
1158
} else if (!strcmp(name, "end")) {