{"thread":{"id":"12745","subject":"[PATCH] Fix read-tree not to discard errors","startedAt":"2008-03-19T05:01:28Z","lastAt":"2008-03-19T05:01:28Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"72361","messageId":"7v3aqn5mtz.fsf@gitster.siamese.dyndns.org","threadId":"12745","inReplyTo":null,"subject":"[PATCH] Fix read-tree not to discard errors","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-19T05:01:28Z","receivedAt":"2008-03-19T05:01:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This fixes the issue identified with recently added tests to t1004\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * Linus's earlier \"root on Solaris\" unlink patch would be a no-op without\n   this fix.\n\n t/t1004-read-tree-m-u-wf.sh |    2 +-\n unpack-trees.c              |    9 ++++++---\n 2 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh\nindex 1356148..570d372 100755\n--- a/t/t1004-read-tree-m-u-wf.sh\n+++ b/t/t1004-read-tree-m-u-wf.sh\n@@ -177,7 +177,7 @@ test_expect_success 'funny symlink in work tree' '\n \n '\n \n-test_expect_failure 'funny symlink in work tree, un-unlink-able' '\n+test_expect_success 'funny symlink in work tree, un-unlink-able' '\n \n \trm -fr a b &&\n \tgit reset --hard &&\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 4b359e0..a59f475 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -54,13 +54,14 @@ static void unlink_entry(char *name, char *last_symlink)\n }\n \n static struct checkout state;\n-static void check_updates(struct unpack_trees_options *o)\n+static int check_updates(struct unpack_trees_options *o)\n {\n \tunsigned cnt = 0, total = 0;\n \tstruct progress *progress = NULL;\n \tchar last_symlink[PATH_MAX];\n \tstruct index_state *index = &o->result;\n \tint i;\n+\tint errs = 0;\n \n \tif (o->update && o->verbose_update) {\n \t\tfor (total = cnt = 0; cnt < index->cache_nr; cnt++) {\n@@ -90,12 +91,13 @@ static void check_updates(struct unpack_trees_options *o)\n \t\tif (ce->ce_flags & CE_UPDATE) {\n \t\t\tce->ce_flags &= ~CE_UPDATE;\n \t\t\tif (o->update) {\n-\t\t\t\tcheckout_entry(ce, &state, NULL);\n+\t\t\t\terrs |= checkout_entry(ce, &state, NULL);\n \t\t\t\t*last_symlink = '\\0';\n \t\t\t}\n \t\t}\n \t}\n \tstop_progress(&progress);\n+\treturn errs != 0;\n }\n \n static inline int call_unpack_fn(struct cache_entry **src, struct unpack_trees_options *o)\n@@ -369,7 +371,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options\n \t\treturn unpack_failed(o, \"Merge requires file-level merging\");\n \n \to->src_index = NULL;\n-\tcheck_updates(o);\n+\tif (check_updates(o))\n+\t\treturn -1;\n \tif (o->dst_index)\n \t\t*o->dst_index = o->result;\n \treturn 0;\n-- \n1.5.5.rc0.122.g8e28f\n"}]}