Re: [PATCH v2 03/17] update-index: read --index-info with strbuf_getline_crlf()
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 4, 2016, 12:27 UTC
- Message-ID
- <alpine.DEB.2.20.1601041308310.14434@virtualbox>
- In-Reply-To
- <1450303398-25900-4-git-send-email-gitster@pobox.com>
Hi Junio,
On Wed, 16 Dec 2015, Junio C Hamano wrote:
Show 13 quoted lines
> diff --git a/builtin/update-index.c b/builtin/update-index.c
> index 7431938..a7a9a7e 100644
> --- a/builtin/update-index.c
> +++ b/builtin/update-index.c
> @@ -473,7 +473,9 @@ static void read_index_info(int line_termination)
> struct strbuf buf = STRBUF_INIT;
> struct strbuf uq = STRBUF_INIT;
>
> - while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
> + while ((line_termination
> + ? strbuf_getline_crlf(&buf, stdin)
> + : strbuf_getline(&buf, stdin, '\0')) != EOF) {
> char *ptr, *tab;This is a problematic change because it does not safeguard for future introduction of a line_termination value other than LF or NUL. I believe the safest would be to change read_index_info() to take a `nul_delimited` parameter instead of the `line_termination` parameter first, and then introduce that change to use strbuf_getline_crlf if !nul_delimited.
Ciao, Dscho