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>maint
parent
c58492d434
commit
c58fc85692
|
@ -241,11 +241,9 @@ struct ref_formatting_state {
|
||||||
|
|
||||||
struct atom_value {
|
struct atom_value {
|
||||||
const char *s;
|
const char *s;
|
||||||
union {
|
|
||||||
struct align align;
|
|
||||||
} u;
|
|
||||||
void (*handler)(struct atom_value *atomv, struct ref_formatting_state *state);
|
void (*handler)(struct atom_value *atomv, struct ref_formatting_state *state);
|
||||||
unsigned long ul; /* used for sorting when not FIELD_STR */
|
unsigned long ul; /* used for sorting when not FIELD_STR */
|
||||||
|
struct used_atom *atom;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -381,7 +379,7 @@ static void align_atom_handler(struct atom_value *atomv, struct ref_formatting_s
|
||||||
push_stack_element(&state->stack);
|
push_stack_element(&state->stack);
|
||||||
new = state->stack;
|
new = state->stack;
|
||||||
new->at_end = end_align_handler;
|
new->at_end = end_align_handler;
|
||||||
new->at_end_data = &atomv->u.align;
|
new->at_end_data = &atomv->atom->u.align;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void if_then_else_handler(struct ref_formatting_stack **stack)
|
static void if_then_else_handler(struct ref_formatting_stack **stack)
|
||||||
|
@ -1090,6 +1088,7 @@ static void populate_value(struct ref_array_item *ref)
|
||||||
struct branch *branch = NULL;
|
struct branch *branch = NULL;
|
||||||
|
|
||||||
v->handler = append_atom;
|
v->handler = append_atom;
|
||||||
|
v->atom = atom;
|
||||||
|
|
||||||
if (*name == '*') {
|
if (*name == '*') {
|
||||||
deref = 1;
|
deref = 1;
|
||||||
|
@ -1154,7 +1153,6 @@ static void populate_value(struct ref_array_item *ref)
|
||||||
v->s = " ";
|
v->s = " ";
|
||||||
continue;
|
continue;
|
||||||
} else if (starts_with(name, "align")) {
|
} else if (starts_with(name, "align")) {
|
||||||
v->u.align = atom->u.align;
|
|
||||||
v->handler = align_atom_handler;
|
v->handler = align_atom_handler;
|
||||||
continue;
|
continue;
|
||||||
} else if (!strcmp(name, "end")) {
|
} else if (!strcmp(name, "end")) {
|
||||||
|
|
Loading…
Reference in New Issue