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

Re: [PATCH 1/3] Fix sparse checkout not removing files from index

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 30, 2010, 19:50 UTC
Message-ID
<20100730195022.GB2448@burratino>
In-Reply-To
<AANLkTi=3pX=k=Pf5SnWt8s=hbvwAXcZdmcqP_+kgCyE5@mail.gmail.com>
Nguyen Thai Ngoc Duy wrote:
> For unpack_trees() only, yes.
Ah, that is what I was missing.
So would the following be correct?
	Subject: unpack-trees: let read-tree -u remove index entries outside sparse area
	To avoid touching the worktree outside a sparse checkout,
	when the update flag is enabled unpack_trees() clears the
	CE_UPDATE and CE_REMOVE flags on entries that do not match the
	sparse pattern before actually committing any updates to the
	index file or worktree.
	The effect on the index was unintentional; sparse checkout was
	never meant to prevent index updates outside the area checked
	out.  And the result is very confusing: for example, after a
	failed merge, currently "git reset --hard" does not reset the
	state completely but an additional "git reset --mixed" will.
	So stop clearing the CE_REMOVE flag.  Instead, maintain a
	CE_WT_REMOVE flag to separately track whether a particular
	file removal should apply to the worktree in addition to the
	index or not.
	The CE_WT_REMOVE flag is used already to mark files that
	should be removed because of a narrowing checkout area.  That
	usage will still apply; do not clear the CE_WT_REMOVE flag
	in that case (detectable because the CE_REMOVE flag is not
	set).
	This bug masked some other bugs illustrated by the test
	suite, which will be addressed by later patches.
	Reported-by: Frédéric Brière <fbriere@fbriere.net>
	Fixes: http://bugs.debian.org/583699
> It'd better be done in one place.

I think I understand better now, and now I agree. (This patch is not a change in the semantics of CE_REMOVE, but just some new unpack-trees bookkeeping.)

> 2010/7/30 Jonathan Nieder <jrnieder@gmail.com>:
Show 7 quoted lines
>> This is a little tricky: the CE_WT_REMOVE case (without CE_REMOVE)
>> represents a narrowing of the checkout and should be preserved,
>> while CE_WT_REMOVE|CE_REMOVE represents a removed index entry and
>> should be changed to just CE_REMOVE.
>
> Yeah. I did wonder if it's worth a comment to explain. I forget why I
> did not add that comment now.

What happens if an index entry is removed at the same time as the checkout is narrowed?

Previous: Nguyen Thai Ngoc DuyNext: Jonathan Nieder
Message 11 of 17 in “Fix sparse checkout not removing files from index”
  1. 1/3 Fix sparse checkout not removing files from indexNguyễn Thái Ngọc Duy, Jul 26, 2010
  2. 2/3 unpack-trees.c: Do not check ce_stage in will_have_skip_worktree()Nguyễn Thái Ngọc Duy, Jul 26, 2010
  3. Jonathan NiederJul 31, 2010
  4. Nguyen Thai Ngoc DuyJul 31, 2010
  5. 3/3 Mark new entries skip-worktree appropriatelyNguyễn Thái Ngọc Duy, Jul 26, 2010
  6. Jonathan NiederJul 31, 2010
  7. Nguyen Thai Ngoc DuyJul 31, 2010
  8. Jonathan NiederJul 31, 2010
  9. Jonathan NiederJul 30, 2010
  10. Nguyen Thai Ngoc DuyJul 30, 2010
  11. Jonathan NiederJul 30, 2010
  12. Jonathan NiederJul 31, 2010
  13. 1/2 t1011 (sparse checkout): style nitpicksJonathan Nieder, Jul 31, 2010
  14. 2/2 read-tree -m -u: always remove relevant files when narrowing checkoutJonathan Nieder, Jul 31, 2010
  15. Nguyen Thai Ngoc DuyJul 31, 2010
  16. Jonathan NiederJul 31, 2010
  17. Nguyen Thai Ngoc DuyJul 31, 2010

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.