Re: [PATCH v3 5/6] rebase -i: support --ignore-date
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 20, 2019, 17:42 UTC
- Message-ID
- <xmqqwof7vim6.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20190820034536.13071-6-rohit.ashiwal265@gmail.com>
Rohit Ashiwal <rohit.ashiwal265@gmail.com> 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.
Show 12 quoted lines
> @@ -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().