Skip to content

Commit

Permalink
sequencer: allow callers of read_author_script() to ignore fields
Browse files Browse the repository at this point in the history
The current callers of the read_author_script() function read name,
email and date from the author script.  Allow callers to signal that
they are not interested in some among these three fields by passing
NULL.

Note that fields that are ignored still must exist and be formatted
correctly in the author script.

Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
r1walz authored and gitster committed Nov 2, 2019
1 parent ba51d2f commit c068bcc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions sequencer.c
Expand Up @@ -824,9 +824,19 @@ int read_author_script(const char *path, char **name, char **email, char **date,
error(_("missing 'GIT_AUTHOR_DATE'"));
if (date_i < 0 || email_i < 0 || date_i < 0 || err)
goto finish;
*name = kv.items[name_i].util;
*email = kv.items[email_i].util;
*date = kv.items[date_i].util;

if (name)
*name = kv.items[name_i].util;
else
free(kv.items[name_i].util);
if (email)
*email = kv.items[email_i].util;
else
free(kv.items[email_i].util);
if (date)
*date = kv.items[date_i].util;
else
free(kv.items[date_i].util);
retval = 0;
finish:
string_list_clear(&kv, !!retval);
Expand Down

0 comments on commit c068bcc

Please sign in to comment.