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

[PATCH 4/5] unpack-trees: do not check for conflict entries too early

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jul 31, 2010, 06:14 UTC
Message-ID
<1280556869-707-5-git-send-email-pclouds@gmail.com>
In-Reply-To
<1280556869-707-1-git-send-email-pclouds@gmail.com>

The idea of sparse checkout is conflict entries should always stay in worktree, regardless $GIT_DIR/info/sparse-checkout. Therefore, ce_stage(ce) usually means no CE_SKIP_WORKTREE. This is true when all entries have been merged into the index, and identical staged entries collapsed.

However, will_have_skip_worktree() since f1f523e (unpack-trees(): ignore worktree check outside checkout area) is also used earlier in verify_* functions, where entries have not been merged to index yet and ce_stage() is not zero. Checking ce_stage() then may provoke unnecessary verification on entries outside checkout area and error out.

This fixes part of test case "read-tree adds to worktree, dirty case". The error

error: Untracked working tree file 'sub/added' would be overwritten by merge.

is now gone and (unfortunately) replaced by another error, which will be addressed in the next patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 unpack-trees.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 1413872..b34ef46 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -135,9 +135,6 @@ static int will_have_skip_worktree(const struct cache_entry *ce, struct unpack_t
 {
 	const char *basename;
 
-	if (ce_stage(ce))
-		return 0;
-
 	basename = strrchr(ce->name, '/');
 	basename = basename ? basename+1 : ce->name;
 	return excluded_from_list(ce->name, ce_namelen(ce), basename, NULL, o->el) <= 0;
@@ -147,7 +144,7 @@ static int apply_sparse_checkout(struct cache_entry *ce, struct unpack_trees_opt
 {
 	int was_skip_worktree = ce_skip_worktree(ce);
 
-	if (will_have_skip_worktree(ce, o))
+	if (!ce_stage(ce) && will_have_skip_worktree(ce, o))
 		ce->ce_flags |= CE_SKIP_WORKTREE;
 	else
 		ce->ce_flags &= ~CE_SKIP_WORKTREE;
-- 
1.7.1.rc1.69.g24c2f7
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 8 of 10 in “nd/fix-sparse-checkout v2”
  1. 0/5 nd/fix-sparse-checkout v2Nguyễn Thái Ngọc Duy, Jul 31, 2010
  2. 1/5 t1011 (sparse checkout): style nitpicksNguyễn Thái Ngọc Duy, Jul 31, 2010
  3. Junio C HamanoAug 2, 2010
  4. Junio C HamanoAug 2, 2010
  5. 2/5 unpack-trees: only clear CE_UPDATE|CE_REMOVE when skip-worktree is always setNguyễn Thái Ngọc Duy, Jul 31, 2010
  6. Jonathan NiederAug 8, 2010
  7. 3/5 unpack-trees: let read-tree -u remove index entries outside sparse areaNguyễn Thái Ngọc Duy, Jul 31, 2010
  8. 4/5 unpack-trees: do not check for conflict entries too earlyNguyễn Thái Ngọc Duy, Jul 31, 2010
  9. 5/5 unpack-trees: mark new entries skip-worktree appropriatelyNguyễn Thái Ngọc Duy, Jul 31, 2010
  10. Jonathan NiederAug 3, 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.