git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: [PATCH 3/3] reset.c: update files when using sparse to avoid data loss.

From
KWKevin Willford <kewillf@microsoft.com>
Date
Apr 11, 2017, 22:30 UTC
Message-ID
<SN2PR03MB2333BCFD2E1A6A400706F94CB7000@SN2PR03MB2333.namprd03.prod.outlook.com>
In-Reply-To
<20170410102429.GB19325@ash>
Show 22 quoted lines
> -----Original Message-----
> From: Duy Nguyen [mailto:pclouds@gmail.com]
> Sent: Monday, April 10, 2017 4:24 AM
> To: Kevin Willford <kcwillford@gmail.com>
> Cc: git@vger.kernel.org; gitster@pobox.com; peff@peff.net; Kevin Willford
> <kewillf@microsoft.com>
> Subject: Re: [PATCH 3/3] reset.c: update files when using sparse to avoid
> data loss.
> 
> On Fri, Apr 07, 2017 at 12:23:57PM -0700, Kevin Willford wrote:
> > When using the sparse checkout feature the git reset command will add
> 
> "git reset" has three different modes. It would be good if you mention what
> mode is affected here. The tests are for --mixed only. I wonder if we need to
> do anything for --hard and --soft?
> 
> --soft touches branch SHA-1 index only, not worktree, so probably not.
> 
> --hard should be handled by unpack_trees(), I think.
> 
> But it would be good to cover these in the commit message as well to stop
> readers from wondering.
Sounds good.
Show 21 quoted lines
> 
> > 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 has 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.
> 
> Hmm.. reading --mixed documentation again ("Resets the index but not
> working tree"), I think the current behavior is expected regardless of skip-
> worktree bits.
> 
> Perhaps the problem is the loss of skip-worktree bits on entries added by
> update_index_from_diff()? If the bits are at the right place, then it should
> not matter if the same version exists on worktree or not and "status" or
> "commit" should work as expected, I think.
> 
> --
> Duy

The loss of the skip-worktree bits is part of the problem if you are talking about modified files. The other issue that I was having is when running a reset and there were files added in the commit that is being reset, there will not be an entry in the index and not a file on disk so the data for that file is completely lost at that point. "status" also doesn't include anything about this loss of data. On modified files status will at least have the file as deleted since there is still an index entry but again the previous version of the file and it's data is lost.

To me this is totally unexpected behavior, for example if I am on a commit where there are only files that where added and run a reset HEAD~1 and then a status, it will show a clean working directory. Regardless of skip-worktree bits the user needs to have the data in the working directory after the reset or data is lost which is always bad.

Kevin
Previous: Duy NguyenNext: Duy Nguyen
Message 10 of 16 in “fix working directory file issues while using sparse-checkout”
  1. 0/3 fix working directory file issues while using sparse-checkoutKevin Willford, Apr 7, 2017
  2. 1/3 merge-recursive.c: conflict using sparse should update fileKevin Willford, Apr 7, 2017
  3. Duy NguyenApr 10, 2017
  4. 2/3 apply.c: do not checkout file when skip-worktree bit setKevin Willford, Apr 7, 2017
  5. Stefan BellerApr 7, 2017
  6. Duy NguyenApr 10, 2017
  7. 3/3 reset.c: update files when using sparse to avoid data loss.Kevin Willford, Apr 7, 2017
  8. Stefan BellerApr 7, 2017
  9. Duy NguyenApr 10, 2017
  10. Kevin WillfordApr 11, 2017
  11. Duy NguyenApr 12, 2017
  12. Kevin WillfordApr 12, 2017
  13. Duy NguyenApr 16, 2017
  14. Duy NguyenApr 17, 2017
  15. Stefan BellerApr 7, 2017
  16. Stefan BellerApr 7, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.