From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 0D27C1F4B4 for ; Mon, 28 Sep 2020 11:43:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726682AbgI1Lkc (ORCPT ); Mon, 28 Sep 2020 07:40:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726657AbgI1Lk3 (ORCPT ); Mon, 28 Sep 2020 07:40:29 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1982C061755 for ; Mon, 28 Sep 2020 04:40:28 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id g4so947744wrs.5 for ; Mon, 28 Sep 2020 04:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=+iT0k2kjhwz1BPcggVrGNP9SOGI46vABgBecsBleWs4=; b=MJEks6bpJdLb2SmIAsF2Td3KB239h6yrUhDEWRMpAWRJmehj/l3iIdSn8GGLCyPjcM vMmzVdtBp7Sfl8ahnyWGSvXSyWksqnCFfpqDXred/ZYLUMjj0EB0Q2ou83Xr0tkCfUyf O2SI8UTNLYFBI+JGY3J8/uDUSrNqgXw50yS97C7ZMNQchw4slHtMoKORmaTbMh+OWzcM r5gnvMwHfwAxYw2mtFO9fIfwUq5xJRqkPP0FhKoSi7CtTzyhkDn3tADFkIBiYcupQbxe Y5Ix0uyxbSbIyGrxXQ/RYRF5SzOOgO/GH6F+x+QGdL6kbsDp21ClYwx2c7UZm3XOvFMe cFEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=+iT0k2kjhwz1BPcggVrGNP9SOGI46vABgBecsBleWs4=; b=G6HQpvHLNCSNikgWt4d3vkjTllDLY/+fo4t3661AXhHh7nkuz1nOyKY/hVau+YIIq2 UR0wFqmZjeAzDf+h8J5fpUIAPxIbN5FQ648DZT2EYMaaM7YHCGY6hIAZLlcRmiFeVey4 fTx9NcNyoGXlWmJAJnN2lpnFiED5JOrw3vhYGDHVJce60ZaZWE5cd0P/2sbyCmhXiCDR jLOppym/KoggofF1SlvCKJ0m8dSzVzsFQkobd8ItZ/VoR6/Fgxtw7ipt85cQiEV7/zuY aDvflSAPnhMG3ejvE4GM9xWSJM8CG7piAKcvRevSemlR+tVbrv+OuX3tyKea7RSwoj1p 4Apw== X-Gm-Message-State: AOAM530VNH/GrT54Pc8OrpBedBqm68FdObtxZxij/rxck3YK/XCLbgUE 2qbdOxCv8atiVagX56Tx81e12EmZku4= X-Google-Smtp-Source: ABdhPJzAeFiJbynOo/UoCWqqaYaHQpGGNLp9lWsjvjJhvuIRljLYVXGk27GeJDoxCMOxKyMP4nYljg== X-Received: by 2002:adf:efc9:: with SMTP id i9mr1272558wrp.187.1601293227202; Mon, 28 Sep 2020 04:40:27 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f16sm1218712wrp.47.2020.09.28.04.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 04:40:26 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Nikita Leonov via GitGitGadget" Date: Mon, 28 Sep 2020 11:40:23 +0000 Subject: [PATCH v2 2/3] credentials: make line reading Windows compatible Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Nikita Leonov Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Nikita Leonov This commit makes reading process regarding credentials compatible with 'CR/LF' line ending. It makes using git more convenient on systems like Windows. Signed-off-by: Nikita Leonov Signed-off-by: Johannes Schindelin --- builtin/credential-cache--daemon.c | 4 ++-- builtin/credential-store.c | 2 +- t/t0302-credential-store.sh | 16 ++++++---------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c index c61f123a3b..17664bb0d5 100644 --- a/builtin/credential-cache--daemon.c +++ b/builtin/credential-cache--daemon.c @@ -99,12 +99,12 @@ static int read_request(FILE *fh, struct credential *c, static struct strbuf item = STRBUF_INIT; const char *p; - strbuf_getline_lf(&item, fh); + strbuf_getline(&item, fh); if (!skip_prefix(item.buf, "action=", &p)) return error("client sent bogus action line: %s", item.buf); strbuf_addstr(action, p); - strbuf_getline_lf(&item, fh); + strbuf_getline(&item, fh); if (!skip_prefix(item.buf, "timeout=", &p)) return error("client sent bogus timeout line: %s", item.buf); *timeout = atoi(p); diff --git a/builtin/credential-store.c b/builtin/credential-store.c index 5331ab151a..d4e90b68df 100644 --- a/builtin/credential-store.c +++ b/builtin/credential-store.c @@ -23,7 +23,7 @@ static int parse_credential_file(const char *fn, return found_credential; } - while (strbuf_getline_lf(&line, fh) != EOF) { + while (strbuf_getline(&line, fh) != EOF) { if (!credential_from_url_gently(&entry, line.buf, 1) && entry.username && entry.password && credential_match(c, &entry)) { diff --git a/t/t0302-credential-store.sh b/t/t0302-credential-store.sh index 716bf1af9f..f2c672e4b6 100755 --- a/t/t0302-credential-store.sh +++ b/t/t0302-credential-store.sh @@ -142,7 +142,7 @@ invalid_credential_test "scheme" ://user:pass@example.com invalid_credential_test "valid host/path" https://user:pass@ invalid_credential_test "username/password" https://pass@example.com -test_expect_success 'get: credentials with DOS line endings are invalid' ' +test_expect_success 'get: credentials with DOS line endings are valid' ' printf "https://user:pass@example.com\r\n" >"$HOME/.git-credentials" && check fill store <<-\EOF protocol=https @@ -150,11 +150,9 @@ test_expect_success 'get: credentials with DOS line endings are invalid' ' -- protocol=https host=example.com - username=askpass-username - password=askpass-password + username=user + password=pass -- - askpass: Username for '\''https://example.com'\'': - askpass: Password for '\''https://askpass-username@example.com'\'': -- EOF ' @@ -172,7 +170,7 @@ test_expect_success 'get: credentials with path and DOS line endings are valid' EOF ' -test_expect_success 'get: credentials with DOS line endings are invalid if path is relevant' ' +test_expect_success 'get: credentials with DOS line endings are valid if path is relevant' ' printf "https://user:pass@example.com/repo.git\r\n" >"$HOME/.git-credentials" && test_config credential.useHttpPath true && check fill store <<-\EOF @@ -181,11 +179,9 @@ test_expect_success 'get: credentials with DOS line endings are invalid if path protocol=https host=example.com path=repo.git - username=askpass-username - password=askpass-password + username=user + password=pass -- - askpass: Username for '\''https://example.com/repo.git'\'': - askpass: Password for '\''https://askpass-username@example.com/repo.git'\'': -- EOF ' -- gitgitgadget