From patchwork Mon Dec 10 18:47:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 10722211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 882E591E for ; Mon, 10 Dec 2018 18:47:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78DA32AC86 for ; Mon, 10 Dec 2018 18:47:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D67A2AC88; Mon, 10 Dec 2018 18:47:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11F8E2AC86 for ; Mon, 10 Dec 2018 18:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728467AbeLJSrS (ORCPT ); Mon, 10 Dec 2018 13:47:18 -0500 Received: from mail-pg1-f173.google.com ([209.85.215.173]:45267 "EHLO mail-pg1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728012AbeLJSrQ (ORCPT ); Mon, 10 Dec 2018 13:47:16 -0500 Received: by mail-pg1-f173.google.com with SMTP id y4so5356529pgc.12 for ; Mon, 10 Dec 2018 10:47:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=h6bw3zh0Owmk640i2fp+7lt4vD41oNHpD0FJtLWvX/Y=; b=iaUEG9snaa9WQRkYZQIQK7Wlc6PJpfAGx/e/b3odFtrsuKFiyeayBpUhzxEhrZSQT5 0mptXJFwLPSk65ItFq//3C9mBlTgadqTEZOS28FhF66avLx/+EE8NZdY96RXiPD3XHHi aDgSsepEOTlEElC4SRCDix3+WoEn5jla52o8FTBLBf2Q7So1YkvxOQ1lsyWjJNYek6mS OPRGhErqRTh382yD1URNL1lk9r+aGoa/H4vmphVWM/n1KR5fMgTuTr3+ouv+NfNE2x/M T5MLrD3fxPtYBqwyVwiy+y3mQFN6LG939qrs6M0fxLVbMWUtLno2cty9h4g09y8fDnjr W6pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=h6bw3zh0Owmk640i2fp+7lt4vD41oNHpD0FJtLWvX/Y=; b=pPy25y0ysTiLP8QT76CaCPrBGDnJfeZG30piOC+La4/cbEwSsWuG7QAA5jC+vqloxZ DEE4E0DR015HKr4sk9tYcSTWzxAkw9R3YD9mwuAGWXQscllVcb+Bxa9D8SmhqfuyMxhv +l0stCG5DvPfDnVWYhg57iZ4Jp98U+oBIL+0S2hj4VyiIPpJ9nDmM75jyDhXfs9J8Jzd E5+UadGxsrBB8pdM9IwJtGjOWhi0Y2hhOw8MWjKx+FeKvRd/wJxUy8BhSiVFVxvi8rnP deZNkjuOwIqNwjOsjB6VYlQG9ffsJC2+jXkis8UGSFnYTNyG4GLBQ9kobm7tF6awX6sp LN6w== X-Gm-Message-State: AA+aEWZsAWSG2yqAOZZPnEIs2AsCriJV1MCTfO9iK1T7S/RmJUbE6Mso 4395xjBzy84PnYFiKjRFkuBQ+kIG X-Google-Smtp-Source: AFSGD/X3+6VGWcjFAlPOt70GsGGFtdcont8yq1RalyG2iH4A3p9/VigeLv9zQwnXdpu05TXd3A25Ag== X-Received: by 2002:a62:4886:: with SMTP id q6mr13794671pfi.182.1544467634933; Mon, 10 Dec 2018 10:47:14 -0800 (PST) Received: from [127.0.0.1] ([40.112.139.188]) by smtp.gmail.com with ESMTPSA id g15sm60299263pfj.131.2018.12.10.10.47.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 10:47:14 -0800 (PST) Date: Mon, 10 Dec 2018 10:47:14 -0800 (PST) X-Google-Original-Date: Mon, 10 Dec 2018 18:47:10 GMT Message-Id: <09a73fe1d30c9fedc2f010fe4df75a9cb000389c.1544467631.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH 1/2] mingw: demonstrate a problem with certain absolute paths Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Schindelin On Windows, there are several categories of absolute paths. One such category starts with a backslash and is implicitly relative to the drive associated with the current working directory. Example: c: git clone https://github.com/git-for-windows/git \G4W should clone into C:\G4W. There is currently a problem with that, in that mingw_mktemp() does not expect the _wmktemp() function to prefix the absolute path with the drive prefix, and as a consequence, the resulting path does not fit into the originally-passed string buffer. The symptom is a "Result too large" error. Reported by Juan Carlos Arevalo Baeza. Signed-off-by: Johannes Schindelin --- t/t5580-clone-push-unc.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/t/t5580-clone-push-unc.sh b/t/t5580-clone-push-unc.sh index ba548df4a9..c2b0082296 100755 --- a/t/t5580-clone-push-unc.sh +++ b/t/t5580-clone-push-unc.sh @@ -17,14 +17,11 @@ fi UNCPATH="$(winpwd)" case "$UNCPATH" in [A-Z]:*) + WITHOUTDRIVE="${UNCPATH#?:}" # Use administrative share e.g. \\localhost\C$\git-sdk-64\usr\src\git # (we use forward slashes here because MSYS2 and Git accept them, and # they are easier on the eyes) - UNCPATH="//localhost/${UNCPATH%%:*}\$/${UNCPATH#?:}" - test -d "$UNCPATH" || { - skip_all='could not access administrative share; skipping' - test_done - } + UNCPATH="//localhost/${UNCPATH%%:*}\$$WITHOUTDRIVE" ;; *) skip_all='skipping UNC path tests, cannot determine current path as UNC' @@ -32,6 +29,18 @@ case "$UNCPATH" in ;; esac +test_expect_failure 'clone into absolute path lacking a drive prefix' ' + USINGBACKSLASHES="$(echo "$WITHOUTDRIVE"/without-drive-prefix | + tr / \\\\)" && + git clone . "$USINGBACKSLASHES" && + test -f without-drive-prefix/.git/HEAD +' + +test -d "$UNCPATH" || { + skip_all='could not access administrative share; skipping' + test_done +} + test_expect_success setup ' test_commit initial ' From patchwork Mon Dec 10 18:47:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 10722209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 525B291E for ; Mon, 10 Dec 2018 18:47:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42E9A2AC86 for ; Mon, 10 Dec 2018 18:47:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 377AC2AC88; Mon, 10 Dec 2018 18:47:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1ACE2AC86 for ; Mon, 10 Dec 2018 18:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728503AbeLJSrS (ORCPT ); Mon, 10 Dec 2018 13:47:18 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:43569 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728420AbeLJSrQ (ORCPT ); Mon, 10 Dec 2018 13:47:16 -0500 Received: by mail-pl1-f194.google.com with SMTP id gn14so5646965plb.10 for ; Mon, 10 Dec 2018 10:47:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=jPuGp/yyrh6ei6UgitHqf2ugLpWewTHKCFwAxf7Ty58=; b=UqXStfqD/CQDionIwFhiA5X1zs3PPIehRFH4m2KQqS/N6M3LJxeLNasTFSVzi/j00L ZjGNJLpu4oNWuGvPhL/GFEy63bUpm4xPST3GeCXIuvPX+1nvOIb2NRd0cTecKTcyiRVd 731/ardg0xyWZrxXIiSvgelx7qE82u4EL1JJsFwDH3VARc7XF7blpZB7VnrKgDIT7Ftz D7o+NFDpfnS9KAb17WX0GwO26AokxZQa9KTpnHLTzkyp1B0S/6rMGT/zoNdvuOnRDB+D oz89wWCi33OthOWwvKILMgjV1icQkVLkPhlzWvaRvqwR6WE3BXb6y27ZYYHu+A5H7yao Lg1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=jPuGp/yyrh6ei6UgitHqf2ugLpWewTHKCFwAxf7Ty58=; b=axOV4ac9ExGK5DR48IZ00n83bTz3j/jLqRYFdoCSnSnqH5gwNObGbrMluIPO4Y1kJE 25WFKhv6chlslUdxJ9CzOeXZg03uzg2hNvByMtBQfhH0Gaq9D6aY3OeWddj3jEBug8Yc jJ+zlQQlzAvathfyUhLpnGp6Dp91zUW5JFwt7Z6hAZyCsPKwqPlqtpD9CL7cvo0sZvaC q2kpl+fPMYWSisllbyPMdg1toNoP4hqD27e+rqhoIuzMztYBhaBGXc7bfCQrOtXKQ3Ur qWPqHEu6Kj9BFkkbMQhw5yES9muV2wU5RNbrMDG/82kiYGHKNkCNjqaAuQn9MHR74+IK XONw== X-Gm-Message-State: AA+aEWahzbI8k9rm0duKK7bSNCfPS+2mi3V7lgpixuCHTK+Hb0EQBh8e jpOUjIt0vm2WiiW4WnLS/K7b/JBh X-Google-Smtp-Source: AFSGD/VxQa9HmMFN5AQA1bGZXv3pKM8oBQAHnAHgaqX1bJzJlFd6hcbB1AkJkm8orXzX7MclWBRhKw== X-Received: by 2002:a17:902:50e:: with SMTP id 14mr12953315plf.141.1544467636069; Mon, 10 Dec 2018 10:47:16 -0800 (PST) Received: from [127.0.0.1] ([40.112.139.188]) by smtp.gmail.com with ESMTPSA id h134sm22257197pfe.27.2018.12.10.10.47.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 10:47:15 -0800 (PST) Date: Mon, 10 Dec 2018 10:47:15 -0800 (PST) X-Google-Original-Date: Mon, 10 Dec 2018 18:47:11 GMT Message-Id: <50ac31ef7f4380f37a0e2d3b75e82b324afee9e3.1544467631.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH 2/2] mingw: allow absolute paths without drive prefix Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Schindelin When specifying an absolute path without a drive prefix, we convert that path internally. Let's make sure that we handle that case properly, too ;-) This fixes the command git clone https://github.com/git-for-windows/git \G4W Signed-off-by: Johannes Schindelin --- compat/mingw.c | 10 +++++++++- t/t5580-clone-push-unc.sh | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 34b3880b29..4d009901d8 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -928,11 +928,19 @@ unsigned int sleep (unsigned int seconds) char *mingw_mktemp(char *template) { wchar_t wtemplate[MAX_PATH]; + int offset = 0; + if (xutftowcs_path(wtemplate, template) < 0) return NULL; + + if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) && + iswalpha(wtemplate[0]) && wtemplate[1] == L':') { + /* We have an absolute path missing the drive prefix */ + offset = 2; + } if (!_wmktemp(wtemplate)) return NULL; - if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0) + if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0) return NULL; return template; } diff --git a/t/t5580-clone-push-unc.sh b/t/t5580-clone-push-unc.sh index c2b0082296..17c38c33a5 100755 --- a/t/t5580-clone-push-unc.sh +++ b/t/t5580-clone-push-unc.sh @@ -29,7 +29,7 @@ case "$UNCPATH" in ;; esac -test_expect_failure 'clone into absolute path lacking a drive prefix' ' +test_expect_success 'clone into absolute path lacking a drive prefix' ' USINGBACKSLASHES="$(echo "$WITHOUTDRIVE"/without-drive-prefix | tr / \\\\)" && git clone . "$USINGBACKSLASHES" &&