From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.0 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 2D9AA1FAD6 for ; Fri, 8 Sep 2017 18:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756859AbdIHSzB (ORCPT ); Fri, 8 Sep 2017 14:55:01 -0400 Received: from mout.web.de ([212.227.15.14]:63354 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756777AbdIHSy7 (ORCPT ); Fri, 8 Sep 2017 14:54:59 -0400 Received: from localhost ([195.198.252.176]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MejjU-1e5kTs2zQe-00OCVo; Fri, 08 Sep 2017 20:54:44 +0200 Date: Fri, 8 Sep 2017 20:54:43 +0200 From: Torsten =?iso-8859-1?Q?B=F6gershausen?= To: Kevin Willford Cc: git@vger.kernel.org, gitster@pobox.com, peff@peff.net, pclouds@gmail.com Subject: Re: [PATCH 1/1] reset: fix reset when using the sparse-checkout feature. Message-ID: <20170908185443.GA15081@tor.lan> References: <20170908180050.25188-1-kewillf@microsoft.com> <20170908180050.25188-2-kewillf@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170908180050.25188-2-kewillf@microsoft.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:CPzwjOjZQ6ZZn7Z1pL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qVD9+U479LVkZ8ucqCw== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, Sep 08, 2017 at 12:00:50PM -0600, Kevin Willford wrote: > When using the sparse checkout feature the git reset command will add > entries to the index that will have the skip-worktree bit off but will > leave the working directory empty. File data is lost because the index > version of the files have been changed but there is nothing that is in the > working directory. This will cause the next status call to show either > deleted for files modified or deleting or nothing for files added. The > added files should be shown as untracked and modified files should be > shown as modified. > > To fix this when the reset is running if there is not a file in the working > directory and if it will be missing with the new index entry or was not > missing in the previous version, we create the previous index version of > the file in the working directory so that status will report correctly > and the files will be availble for the user to deal with. > > Signed-off-by: Kevin Willford [] > diff --git a/t/t7114-reset-sparse-checkout.sh b/t/t7114-reset-sparse-checkout.sh > new file mode 100755 > index 0000000000..f2a5426847 > --- /dev/null > +++ b/t/t7114-reset-sparse-checkout.sh > @@ -0,0 +1,60 @@ > +#!/bin/sh > + > +test_description='reset when using a sparse-checkout' > + > +. ./test-lib.sh > + > +# reset using a sparse-checkout file > + > +test_expect_success 'setup' ' > + test_tick && Do we need a test_tick here ? > + echo "checkout file" >c && > + echo "modify file" >m && > + echo "delete file" >d && > + git add . && > + git commit -m "initial commit" && > + echo "added file" >a && > + echo "modification of a file" >m && > + git rm d && > + git add . && > + git commit -m "second commit" && > + git checkout -b endCommit > +' > + > +test_expect_success 'reset when there is a sparse-checkout' ' > + echo "/c" >.git/info/sparse-checkout && > + test_config core.sparsecheckout true && > + git checkout -b resetBranch && > + test_path_is_missing m && > + test_path_is_missing a && > + test_path_is_missing d && > + git reset HEAD~1 && > + test "checkout file" = "$(cat c)" && > + test "modification of a file" = "$(cat m)" && > + test "added file" = "$(cat a)" && > + test_path_is_missing d > +' > +