Re: [PATCH v5 08/22] rebase: use read_oneliner()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 8, 2020, 00:26 UTC
- Message-ID
- <xmqq8sj6rffj.fsf@gitster.c.googlers.com>
- In-Reply-To
- <0cc279fc14dd27ed2606064d236115aa72551dce.1586269543.git.liu.denton@gmail.com>
Denton Liu <liu.denton@gmail.com> writes:
Show 11 quoted lines
> Since in sequencer.c, read_one() basically duplicates the functionality > of read_oneliner(), reduce code duplication by replacing read_one() with > read_oneliner(). > > This was done with the following Coccinelle script > > @@ > expression a, b; > @@ > - read_one(a, b) > + !read_oneliner(b, a, READ_ONELINER_WARN_NON_EXISTENCE)
WARN_MISSING, you mean?
Show 9 quoted lines
> -/* Read one file, then strip line endings */
> -static int read_one(const char *path, struct strbuf *buf)
> -{
> - if (strbuf_read_file(buf, path, 0) < 0)
> - return error_errno(_("could not read '%s'"), path);
> - strbuf_trim_trailing_newline(buf);
> - return 0;
> -}
> -OK. Both functions trim the end-of-line marker from the end of the string, so this is truly a no-op that reduces the code. Good.