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

[PATCH 1/3] unpack-trees: handle failure in verify_absent

From
Clemens Buchacher <drizzd@aon.at>
Date
Jan 1, 2009, 20:54 UTC
Message-ID
<1230843273-11056-2-git-send-email-drizzd@aon.at>
In-Reply-To
<1230843273-11056-1-git-send-email-drizzd@aon.at>
Commit 203a2fe1 (Allow callers of unpack_trees() to handle failure)
changed the "die on error" behavior to "return failure code".
verify_absent did not handle errors returned by
verify_clean_subdirectory, however.
---
 t/t1001-read-tree-m-2way.sh |   24 ++++++++++++++++++++++++
 unpack-trees.c              |    8 +++++---
 2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh
index 4b44e13..7f6ab31 100755
--- a/t/t1001-read-tree-m-2way.sh
+++ b/t/t1001-read-tree-m-2way.sh
@@ -341,4 +341,28 @@ test_expect_success \
      check_cache_at DF/DF dirty &&
      :'
 
+test_expect_success \
+    'a/b (untracked) vs a case setup.' \
+    'rm -f .git/index &&
+     : >a &&
+     git update-index --add a &&
+     treeM=`git write-tree` &&
+     echo treeM $treeM &&
+     git ls-tree $treeM &&
+     git ls-files --stage >treeM.out &&
+
+     rm -f a &&
+     git update-index --remove a &&
+     mkdir a &&
+     : >a/b &&
+     treeH=`git write-tree` &&
+     echo treeH $treeH &&
+     git ls-tree $treeH'
+
+test_expect_success \
+    'a/b (untracked) vs a, plus c/d case test.' \
+    '! git read-tree -u -m "$treeH" "$treeM" &&
+     git ls-files --stage &&
+     test -f a/b'
+
 test_done
diff --git a/unpack-trees.c b/unpack-trees.c
index 54f301d..a736947 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -588,7 +588,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
 		return 0;
 
 	if (!lstat(ce->name, &st)) {
-		int cnt;
+		int ret;
 		int dtype = ce_to_dtype(ce);
 		struct cache_entry *result;
 
@@ -616,7 +616,9 @@ static int verify_absent(struct cache_entry *ce, const char *action,
 			 * files that are in "foo/" we would lose
 			 * it.
 			 */
-			cnt = verify_clean_subdirectory(ce, action, o);
+			ret = verify_clean_subdirectory(ce, action, o);
+			if (ret < 0)
+				return ret;
 
 			/*
 			 * If this removed entries from the index,
@@ -635,7 +637,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
 			 * We need to increment it by the number of
 			 * deleted entries here.
 			 */
-			o->pos += cnt;
+			o->pos += ret;
 			return 0;
 		}
 
-- 
1.6.1
Previous: Clemens BuchacherNext: Clemens Buchacher
Message 2 of 20 in “unpack-trees: fix D/F conflict bugs in verify_absent”
  1. Clemens BuchacherJan 1, 2009
  2. 1/3 unpack-trees: handle failure in verify_absentClemens Buchacher, Jan 1, 2009
  3. 2/3 unpack-trees: fix path search bug in verify_absentClemens Buchacher, Jan 1, 2009
  4. 3/3 unpack-trees: remove redundant path search in verify_absentClemens Buchacher, Jan 1, 2009
  5. Junio C HamanoJan 6, 2009
  6. Johannes SchindelinJan 2, 2009
  7. Miklos VajnaJan 3, 2009
  8. Johannes SchindelinJan 2, 2009
  9. Clemens BuchacherJan 3, 2009
  10. Johannes SchindelinJan 3, 2009
  11. Junio C HamanoJan 4, 2009
  12. Clemens BuchacherJan 4, 2009
  13. Johannes SchindelinJan 6, 2009
  14. 0/2 unpack-trees: handle lstat failures in verify_absentJonathan Nieder, Jan 13, 2011
  15. 1/2 unpack-trees: handle lstat failure for existing directoryJonathan Nieder, Jan 13, 2011
  16. Miles BaderJan 13, 2011
  17. Jonathan NiederJan 13, 2011
  18. 2/2 unpack-trees: handle lstat failure for existing fileJonathan Nieder, Jan 13, 2011
  19. Clemens BuchacherJan 13, 2011
  20. Junio C HamanoJan 1, 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.