Skip to content

Commit c068bcc

Browse files
r1walzgitster
authored andcommitted
sequencer: allow callers of read_author_script() to ignore fields
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba51d2f commit c068bcc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

sequencer.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,9 +824,19 @@ int read_author_script(const char *path, char **name, char **email, char **date,
824824
error(_("missing 'GIT_AUTHOR_DATE'"));
825825
if (date_i < 0 || email_i < 0 || date_i < 0 || err)
826826
goto finish;
827-
*name = kv.items[name_i].util;
828-
*email = kv.items[email_i].util;
829-
*date = kv.items[date_i].util;
827+
828+
if (name)
829+
*name = kv.items[name_i].util;
830+
else
831+
free(kv.items[name_i].util);
832+
if (email)
833+
*email = kv.items[email_i].util;
834+
else
835+
free(kv.items[email_i].util);
836+
if (date)
837+
*date = kv.items[date_i].util;
838+
else
839+
free(kv.items[date_i].util);
830840
retval = 0;
831841
finish:
832842
string_list_clear(&kv, !!retval);

0 commit comments

Comments
 (0)