Subject: Re: [PATCH v3 5/6] rebase -i: support --ignore-date

From: Junio C Hamano <[email-masked]>
Date: Tue, 20 Aug 2019 10:42:25 -0700

Rohit Ashiwal <[email-masked]> writes:

> +/* Construct a free()able author string with current time as the author date */
> +static char *ignore_author_date(const char *author)
> +{
> +	int len = strlen(author);

Mental note: ignore_author_date() would not allow author==NULL as its input.

> @@ -1020,10 +1047,20 @@ static int run_git_commit(struct repository *r,
>  
>  		if (res <= 0)
>  			res = error_errno(_("could not read '%s'"), defmsg);
> -		else
> +		else {
> +			if (opts->ignore_date) {
> +				char *new_author = ignore_author_date(author);
> +				if (!author)
> +					BUG("ignore-date can only be used with "
> +					    "rebase, which must set the author "
> +					    "before committing the tree");

Yet, author is used and then checked for NULL-ness, which is
backwards.  Before we have a chance to issue this BUG(), we would
already have segfaulted inside ignore_author_date().