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

[RFC PATCH v4 13/19] unpack-trees.c: generalize verify_* functions

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Aug 20, 2009, 13:47 UTC
Message-ID
<1250776033-12395-14-git-send-email-pclouds@gmail.com>
In-Reply-To
<1250776033-12395-13-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 unpack-trees.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 6a51a69..8eb4b70 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -452,8 +452,9 @@ static int same(struct cache_entry *a, struct cache_entry *b)
  * When a CE gets turned into an unmerged entry, we
  * want it to be up-to-date
  */
-static int verify_uptodate(struct cache_entry *ce,
-		struct unpack_trees_options *o)
+static int verify_uptodate_1(struct cache_entry *ce,
+				   struct unpack_trees_options *o,
+				   const char *error_msg)
 {
 	struct stat st;
 
@@ -478,7 +479,13 @@ static int verify_uptodate(struct cache_entry *ce,
 	if (errno == ENOENT)
 		return 0;
 	return o->gently ? -1 :
-		error(ERRORMSG(o, not_uptodate_file), ce->name);
+		error(error_msg, ce->name);
+}
+
+static int verify_uptodate(struct cache_entry *ce,
+			   struct unpack_trees_options *o)
+{
+	return verify_uptodate_1(ce, o, ERRORMSG(o, not_uptodate_file));
 }
 
 static void invalidate_ce_path(struct cache_entry *ce, struct unpack_trees_options *o)
@@ -586,8 +593,9 @@ static int icase_exists(struct unpack_trees_options *o, struct cache_entry *dst,
  * We do not want to remove or overwrite a working tree file that
  * is not tracked, unless it is ignored.
  */
-static int verify_absent(struct cache_entry *ce, const char *action,
-			 struct unpack_trees_options *o)
+static int verify_absent_1(struct cache_entry *ce, const char *action,
+				 struct unpack_trees_options *o,
+				 const char *error_msg)
 {
 	struct stat st;
 
@@ -667,6 +675,11 @@ static int verify_absent(struct cache_entry *ce, const char *action,
 	}
 	return 0;
 }
+static int verify_absent(struct cache_entry *ce, const char *action,
+			 struct unpack_trees_options *o)
+{
+	return verify_absent_1(ce, action, o, ERRORMSG(o, would_lose_untracked));
+}
 
 static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
 		struct unpack_trees_options *o)
-- 
1.6.3.GIT
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 14 of 27 in “Sparse checkout”
  1. 00/19 Sparse checkoutNguyễn Thái Ngọc Duy, Aug 20, 2009
  2. 01/19 update-index: refactor mark_valid() in preparation for new optionsNguyễn Thái Ngọc Duy, Aug 20, 2009
  3. 02/19 Add test-index-versionNguyễn Thái Ngọc Duy, Aug 20, 2009
  4. 03/19 Introduce "skip-worktree" bit in index, teach Git to get/set this bitNguyễn Thái Ngọc Duy, Aug 20, 2009
  5. 04/19 Teach Git to respect skip-worktree bit (reading part)Nguyễn Thái Ngọc Duy, Aug 20, 2009
  6. 05/19 Teach Git to respect skip-worktree bit (writing part)Nguyễn Thái Ngọc Duy, Aug 20, 2009
  7. 06/19 Avoid writing to buffer in add_excludes_from_file_1()Nguyễn Thái Ngọc Duy, Aug 20, 2009
  8. 07/19 Read .gitignore from index if it is skip-worktreeNguyễn Thái Ngọc Duy, Aug 20, 2009
  9. 08/19 unpack-trees(): carry skip-worktree bit over in merged_entry()Nguyễn Thái Ngọc Duy, Aug 20, 2009
  10. 09/19 excluded_1(): support exclude files in indexNguyễn Thái Ngọc Duy, Aug 20, 2009
  11. 10/19 dir.c: export excluded_1() and add_excludes_from_file_1()Nguyễn Thái Ngọc Duy, Aug 20, 2009
  12. 11/19 Introduce "sparse checkout"Nguyễn Thái Ngọc Duy, Aug 20, 2009
  13. 12/19 unpack-trees(): add CE_WT_REMOVE to remove on worktree aloneNguyễn Thái Ngọc Duy, Aug 20, 2009
  14. 13/19 unpack-trees.c: generalize verify_* functionsNguyễn Thái Ngọc Duy, Aug 20, 2009
  15. 14/19 unpack-trees(): "enable" sparse checkout and load $GIT_DIR/info/sparse-checkoutNguyễn Thái Ngọc Duy, Aug 20, 2009
  16. 15/19 unpack_trees(): apply $GIT_DIR/info/sparse-checkout to the final indexNguyễn Thái Ngọc Duy, Aug 20, 2009
  17. 16/19 unpack-trees(): ignore worktree check outside checkout areaNguyễn Thái Ngọc Duy, Aug 20, 2009
  18. 17/19 read-tree: add --no-sparse-checkout to disable sparse checkout supportNguyễn Thái Ngọc Duy, Aug 20, 2009
  19. 18/19 Add tests for sparse checkoutNguyễn Thái Ngọc Duy, Aug 20, 2009
  20. 19/19 sparse checkout: inhibit empty worktreeNguyễn Thái Ngọc Duy, Aug 20, 2009
  21. Nguyen Thai Ngoc DuyAug 21, 2009
  22. Junio C HamanoAug 21, 2009
  23. Nguyen Thai Ngoc DuyAug 22, 2009
  24. Jakub NarebskiAug 20, 2009
  25. Matthieu MoyAug 20, 2009
  26. Junio C HamanoAug 21, 2009
  27. Nguyen Thai Ngoc DuyAug 21, 2009

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.