@matheusbsbs / matheus-bagliano / commits / c068bcc59b
Fork 0

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 <rohit.ashiwal265@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rohit Ashiwal committed Nov 1, 2019 at 19:29 UTC c068bcc59b4f16322a77b6a47b53d44b05c51fec
1 file changed +13 -3
sequencer.c
+13 -3
@@ -824,9 +824,19 @@ int read_author_script(const char *path, char **name, char **email, char **date,
824 error(_("missing 'GIT_AUTHOR_DATE'"));
825 if (date_i < 0 || email_i < 0 || date_i < 0 || err)
826 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);
840 retval = 0;
841 finish:
842 string_list_clear(&kv, !!retval);