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

[PATCH] Fix read-tree not to discard errors

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 19, 2008, 05:01 UTC
Message-ID
<7v3aqn5mtz.fsf@gitster.siamese.dyndns.org>
This fixes the issue identified with recently added tests to t1004
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * Linus's earlier "root on Solaris" unlink patch would be a no-op without
   this fix.
 t/t1004-read-tree-m-u-wf.sh |    2 +-
 unpack-trees.c              |    9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh
index 1356148..570d372 100755
--- a/t/t1004-read-tree-m-u-wf.sh
+++ b/t/t1004-read-tree-m-u-wf.sh
@@ -177,7 +177,7 @@ test_expect_success 'funny symlink in work tree' '
 
 '
 
-test_expect_failure 'funny symlink in work tree, un-unlink-able' '
+test_expect_success 'funny symlink in work tree, un-unlink-able' '
 
 	rm -fr a b &&
 	git reset --hard &&
diff --git a/unpack-trees.c b/unpack-trees.c
index 4b359e0..a59f475 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -54,13 +54,14 @@ static void unlink_entry(char *name, char *last_symlink)
 }
 
 static struct checkout state;
-static void check_updates(struct unpack_trees_options *o)
+static int check_updates(struct unpack_trees_options *o)
 {
 	unsigned cnt = 0, total = 0;
 	struct progress *progress = NULL;
 	char last_symlink[PATH_MAX];
 	struct index_state *index = &o->result;
 	int i;
+	int errs = 0;
 
 	if (o->update && o->verbose_update) {
 		for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
@@ -90,12 +91,13 @@ static void check_updates(struct unpack_trees_options *o)
 		if (ce->ce_flags & CE_UPDATE) {
 			ce->ce_flags &= ~CE_UPDATE;
 			if (o->update) {
-				checkout_entry(ce, &state, NULL);
+				errs |= checkout_entry(ce, &state, NULL);
 				*last_symlink = '\0';
 			}
 		}
 	}
 	stop_progress(&progress);
+	return errs != 0;
 }
 
 static inline int call_unpack_fn(struct cache_entry **src, struct unpack_trees_options *o)
@@ -369,7 +371,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
 		return unpack_failed(o, "Merge requires file-level merging");
 
 	o->src_index = NULL;
-	check_updates(o);
+	if (check_updates(o))
+		return -1;
 	if (o->dst_index)
 		*o->dst_index = o->result;
 	return 0;
-- 
1.5.5.rc0.122.g8e28f
Message 1 of 1 in “Fix read-tree not to discard errors”
  1. Fix read-tree not to discard errorsJunio C Hamano, Mar 19, 2008

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.