From patchwork Mon Jan 21 19:50:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Peart X-Patchwork-Id: 10774475 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 3AA1513B4 for ; Mon, 21 Jan 2019 19:50:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29D232A9AB for ; Mon, 21 Jan 2019 19:50:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DB3A2A9AE; Mon, 21 Jan 2019 19:50:24 +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 BF4AD2A9AB for ; Mon, 21 Jan 2019 19:50:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728033AbfAUTuW (ORCPT ); Mon, 21 Jan 2019 14:50:22 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:42076 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727491AbfAUTuV (ORCPT ); Mon, 21 Jan 2019 14:50:21 -0500 Received: by mail-qk1-f194.google.com with SMTP id 68so12908915qke.9 for ; Mon, 21 Jan 2019 11:50:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jt0TwFalnoOs3X+JISct5xn71tVqgNgcixSW2MBMuJE=; b=Jk33fwqr8/4gyqC9LBVjqod1asMUYHvhxBHPKsrlz8cEvdFeSigIhYVsYOQgbBxglc RRduwiSDbdkakOsFspzgUgRCfR2giikHNeW6pZ2J87OcmARxzYYXwLcA3QSTjPkuIcIA JO54TvKOH/i2G/OE1L7odbHJToYv1+0zamj3FGLRaXvYXOsCiH5Lmr5n4514QRKPTTAa tD5WaM6eeY3ghx6VbaTDo1rRUhKHlTJFFjwmZWGuWyPc6aeBs9rWx26q0K0T+/kDiNMQ ROMMh4vCZpoIaWaDrqrjcVUQCaNPXBsKq9n/tzLCG//9/Y0Rpfy/lvMMDPPrrYShQsjy NxSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jt0TwFalnoOs3X+JISct5xn71tVqgNgcixSW2MBMuJE=; b=GepYv/mwWDkuD6IKldxbQ85UbLpD4cgQ0saPjLes247APrqFA40ZqMvGii3/nuOfqL uGHBruV8CMFGyr4fzGDo2L+LSdymQGVb2EiNtRqQYgEjXo+x6vLECHdoxepl+NeFaz24 f7rWjSpx9mM2fAHLdsvtJ6i0Cab5TJf/QuIod5qHbuHskVVaJTyijJ11GliG8omR1FoV heMw2OW7PzChPaFhEi83QVNUUdv0pmVZ66PxBWfzM3u/Q9VCVrK/QKxlaCVRJ2wOwppA GlT2aAXFK36xMAQRUgy8bb4QnX5PCVs+aiRkCvIG2+sxNS66h5ML2S6fSl654eBBvbsb JGSw== X-Gm-Message-State: AJcUukeboWdmX6lh3Eo9JWIcGfuBowOD0K5A33PCY7ZQeDVRuS24jpSF T/qPt006udhmv79EMzX0zGIbLRW8u9Q= X-Google-Smtp-Source: ALg8bN67doFZ0kGyxsbeWLP9qBx46Q812tfq2A2GSu7wfXz6cLzSLqmVj0YcSaU8ApKwcTpED6XvXg== X-Received: by 2002:ae9:f212:: with SMTP id m18mr25224501qkg.5.1548100220036; Mon, 21 Jan 2019 11:50:20 -0800 (PST) Received: from localhost.localdomain (70-33-148-227.unassigned.ntelos.net. [70.33.148.227]) by smtp.gmail.com with ESMTPSA id n62sm22760625qkn.43.2019.01.21.11.50.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 11:50:18 -0800 (PST) From: Ben Peart To: git@vger.kernel.org Cc: asottile@umich.edu, benpeart@microsoft.com, gitster@pobox.com, pclouds@gmail.com, peartben@gmail.com Subject: [PATCH v2 1/2] checkout: add test to demonstrate regression with checkout -b on initial commit Date: Mon, 21 Jan 2019 14:50:07 -0500 Message-Id: <20190121195008.8700-2-peartben@gmail.com> X-Mailer: git-send-email 2.19.1.gvfs.1.16.g9d1374d In-Reply-To: <20190121195008.8700-1-peartben@gmail.com> References: <20190118185558.17688-1-peartben@gmail.com> <20190121195008.8700-1-peartben@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Peart Commit fa655d8411 (checkout: optimize "git checkout -b ", 2018-08-16) introduced an unintentional change in behavior for 'checkout -b' after doing 'clone --no-checkout'. Add a test to demonstrate the changed behavior to be used in a later patch to verify the fix. Signed-off-by: Ben Peart --- t/t2018-checkout-branch.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index 2131fb2a56..6da2d4e68f 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -198,4 +198,13 @@ test_expect_success 'checkout -B to the current branch works' ' test_dirty_mergeable ' +test_expect_failure 'checkout -b after clone --no-checkout does a checkout of HEAD' ' + git init src && + test_commit -C src a && + rev="$(git -C src rev-parse HEAD)" && + git clone --no-checkout src dest && + git -C dest checkout "$rev" -b branch && + test_path_is_file dest/a.t +' + test_done From patchwork Mon Jan 21 19:50:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Peart X-Patchwork-Id: 10774477 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 5362314E5 for ; Mon, 21 Jan 2019 19:50:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 431D92A9AB for ; Mon, 21 Jan 2019 19:50:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 378A72A9AE; Mon, 21 Jan 2019 19:50:25 +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 D38252A9AB for ; Mon, 21 Jan 2019 19:50:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728047AbfAUTuY (ORCPT ); Mon, 21 Jan 2019 14:50:24 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:39364 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727992AbfAUTuW (ORCPT ); Mon, 21 Jan 2019 14:50:22 -0500 Received: by mail-qt1-f195.google.com with SMTP id u47so24856834qtj.6 for ; Mon, 21 Jan 2019 11:50:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3p+p72AyL7LyPzc8X9PKKJGnbDwxT/voGvI4ovNy9LE=; b=JpCsNwD2JG+zIikn62FLNTlLp0G8T/gf6roOQytxT3qUBpnfi0BmQkzNwH22LuB0Lp BdB0gG1/4Sq3p1IMidRGc8O6eP3ui3kOv3wmmpY3Lcu6kmGV/dHMYCrkSjI9qKMaS+5k zlE2xPS0HtnYd3yfm2MswXMe5E/p1XoAD7P5GCNDlASfRfUou4dgPFO0zx3+hUEjpXAX /H6tLaGdoDLESSv1G8owABY5FlDp+N10bB8ESruarwLNP3iEEev2Vm22B+8zkQxHPTNV lyd/3RmDPEH8zaeMPpTCzMtFeOGzc0FLkYrWcrrWFGJFZc8E5a4tGU7lXk7VWpNDyZqr imdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3p+p72AyL7LyPzc8X9PKKJGnbDwxT/voGvI4ovNy9LE=; b=hVviLxWWi0HBYh8toGOucsc3eTfyigPcJ8wFOAajq6+ikcB6H8fwW8ATaxf4aO+e+b i7z4rTe12Lp/2G1pswCWUKr7Ma5IYNkAN/cw3ElRBwtulZjNvXOw9rqTAR7ZLsjPrZi4 HEzC4NOW+8VPC/JeJ0sJteCz8EHThngZ2ZfNBogywe1C463vQK6ucXcJVAAKMTHoQyUV eeStt/WH3bvFZ7qEHE+UEPKMesd11k/3WCWEesclzpYs/JApv+E6UvG8UDeDHuDrfFaO 9wwe+fdACtYvxlMgU/1T8dS8Ijl8WPnZ14aj7NQALMAAeLXSGqo2hBmzRYY34gTx8E+K ZUZg== X-Gm-Message-State: AJcUukdP4vSDBhZSAe9tOcfRQAAHx3ctiMFAvBrq0wh8qSFwV397+PBd sedFta8AuD+z5qeLOqMxpqP+h0Q05HM= X-Google-Smtp-Source: ALg8bN7IIQK3v7Bh63LnmamHA7TBkzgEHJZ2mnzG5RyeZ1TGccqaZJ3iD06FS6lVhmGvOOy/Ul3EOQ== X-Received: by 2002:a0c:b044:: with SMTP id l4mr27184587qvc.80.1548100221202; Mon, 21 Jan 2019 11:50:21 -0800 (PST) Received: from localhost.localdomain (70-33-148-227.unassigned.ntelos.net. [70.33.148.227]) by smtp.gmail.com with ESMTPSA id n62sm22760625qkn.43.2019.01.21.11.50.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 11:50:20 -0800 (PST) From: Ben Peart To: git@vger.kernel.org Cc: asottile@umich.edu, benpeart@microsoft.com, gitster@pobox.com, pclouds@gmail.com, peartben@gmail.com Subject: [PATCH v2 2/2] checkout: fix regression in checkout -b on intitial checkout Date: Mon, 21 Jan 2019 14:50:08 -0500 Message-Id: <20190121195008.8700-3-peartben@gmail.com> X-Mailer: git-send-email 2.19.1.gvfs.1.16.g9d1374d In-Reply-To: <20190121195008.8700-1-peartben@gmail.com> References: <20190118185558.17688-1-peartben@gmail.com> <20190121195008.8700-1-peartben@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Peart When doing a 'checkout -b' do a full checkout including updating the working tree when doing the initial checkout. This fixes the regression in behavior caused by fa655d8411 (checkout: optimize "git checkout -b ", 2018-08-16) Signed-off-by: Ben Peart --- builtin/checkout.c | 7 +++++++ t/t2018-checkout-branch.sh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 6fadf412e8..9c6e94319e 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -592,6 +592,13 @@ static int skip_merge_working_tree(const struct checkout_opts *opts, * Remaining variables are not checkout options but used to track state */ + /* + * Do the merge if this is the initial checkout + * + */ + if (!file_exists(get_index_file())) + return 0; + return 1; } diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index 6da2d4e68f..c5014ad9a6 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -198,7 +198,7 @@ test_expect_success 'checkout -B to the current branch works' ' test_dirty_mergeable ' -test_expect_failure 'checkout -b after clone --no-checkout does a checkout of HEAD' ' +test_expect_success 'checkout -b after clone --no-checkout does a checkout of HEAD' ' git init src && test_commit -C src a && rev="$(git -C src rev-parse HEAD)" &&