Week 11: Another possible approach at mailmap options
This week was a bit unproductive as I was sick for a few days and couldn’t
really get any work done in that time. I was able to add the docs and the tests
to the changed implementation from Christian’s comments last week though. So now
the implementation looks a bit like this
enum {
EO_RAW = 1<<0,
EO_TRIM = 1<<1,
EO_LOCALPART = 1<<2,
EO_MAILMAP = 1<<3,
} option;
We parse the options of the given relevant format with
email_atom_option_parser()
and loop through it in person_email_atom_parser()
to store them in struct used_atom
(the looping is done atmost two times, with
the only option we can comibine trim
or localpart
is with mailmap
).
We then perform bit operations to get the asked values which are stored in
struct used_atom
. This part is done in copy_email()
which is then called by
grab_person()
to get the values according to the option parsing.
Another approach
In the above way of implementing things, we transform the buffer passed to get
the email value, according to the options, to conform with .mailmap file or the
config variable set. However, we do this transforming step precisely thrice.
Once in copy_line()
, whenever we pass something like %(author)
to
--format=<format>
. In copy_name()
, for %(authorname:mailmap)
and related
formats. In copy_email()
, for %(authoremail:mailmap)
and related formats and
their respective options.
We can avoid doing this by directly changing the buffer we pass to
find_wholine()
by doing something like
if (mailmap.use)
change_to_mailmap_value(buf);
in grab_person()
.
We could also change this in find_wholine()
itself. This is faster because we
only grab a buffer till the wholines (that is author, committer and tagger
information) and then apply mailmap to the particular headers.
Parsing the options remains the same, we only change the above mentioned code so
that we don’t have to individually call change_to_mailmap_value()
in
value-grabbing functions. This is still in its testing phase and is just an idea
and I don’t know if it’ll work (I did test it maunally though and it seems to
have some bugs, usually of memory allocation). I still have to discuss this with
Christian and Hariom. I thought I’ll do that with the code all written.
This is all the work that I did past week and nothing else. I have pushed none
of it (not even the work with Christian’s comments) because there seems to be a
bug with memory allocation in copy_email()
. I guess this is because some
conditions are not being tests and the variables start accessing or duplicating
bogus memory. I’ll have to figure it out.
‘til next time,
Kousik